System update with yum

application background

Suppose your network has been connected, and now you want to update the entire system, and you need to automatically update the system at 2:15 am every day. How to do it?

 

solution

Step 1: Run the system update command, the first update will take a long time.

[root@localhost bin]# yum -y update

Step 2: Execute the same command for the second time, the speed is very fast, and the command is executed as follows.

[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

Step 3: Edit the crontab file of the scheduled task, the key is the last line

[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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326403681&siteId=291194637