利用yum进行系统更新

应用背景

假设你的网络已经通了,目前你要进行整个系统的更新,同时需要每天凌晨2:15自动进行系统更新,该如何操作?

解决方案

第一步:进行系统更新命令,第一次进行更新,时间会比较长。

[root@localhost bin]# yum -y update

第二步:第二次再执行同样的命令,速度很快,命令执行如下。

[root@localhost bin]# yum -y update

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

 * base: centos.ustc.edu.cn

 * extras: centos.ustc.edu.cn

 * updates: centos.ustc.edu.cn

No packages marked for update

第三步:编辑定时任务文件crontab,关键是最后一行

[root@localhost bin]# vim /etc/crontab

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

# For details see man 4 crontabs

# Example of job definition:

# .---------------- minute (0 - 59)

# |  .------------- hour (0 - 23)

# |  |  .---------- day of month (1 - 31)

# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...

# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

# |  |  |  |  |

# *  *  *  *  * user-name  command to be executed

15 2 * * * root /usr/bin/yum -y update

猜你喜欢

转载自cakin24.iteye.com/blog/2335604