CentOS Automatic Updates
CentOS Automatic Updates tutorial.
This tutorial apply to Centos 5.x, 6.x and 7.x.
The yum package supplied with CentOS 5.0 includes scripts to perform full system updates every day. To activate automatic daily updates, enter this command:
su -c '/sbin/chkconfig --level 345 yum on; /sbin/service yum start'
At the prompt, enter the password for the root account.
There is no separate yum service that runs on your system. The command given above enables the control script /etc/rc.d/init.d/yum. This control script activates the script /etc/cron.daily/yum.cron, which causes the cron service to perform the system update automatically at 4am each day.
To get started, install yum-cron:
yum -y install yum-cron
By default, it’s configured to download all of the available updates and apply them immediately after downloading. Reports will be emailed to the root user on the system. To change these settings, just open /etc/sysconfig/yum-cron in your favorite text editor and adjust wherever setting you need to change:
The important settings to mention are:
# Don't install, just check (valid: yes|no) CHECK_ONLY=no # Don't install, just check and download (valid: yes|no) # Implies CHECK_ONLY=yes (gotta check first to see what to download) DOWNLOAD_ONLY=no # if MAILTO is set and the mail command is available, the mail command is used to deliver yum output # by default MAILTO is unset, so crond mails the output by itself # example: MAILTO=root MAILTO= # you may set DAYS_OF_WEEK to the days of the week you want to run # default is every day #DAYS_OF_WEEK="0123456"
If you want to exclude some packages only from the automatic update you can edit the file /etc/sysconfig/yum-cron and set the option YUM_PARAMETER with -x packagename, you have to repeat the -x for every package that you want to exclude, such as:
YUM_PARAMETER="-x kernel* -x php*"
The cron jobs from the yum-cron package are active immediately after installing the package and there’s no extra configuration necessary. The job will be run when your normal daily cron jobs are set to run.
chkconig yum-cron on service yum-cron start
Although CentOS 6.x Instructions will work for CentOS 7.0, you could upgrade the installation process to be completely CentOS 7.0 compatible:
yum install yum-cron systemctl enable yum-cron.service systemctl start yum-cron.service
.conf file (Configuration) located at: /etc/yum/yum-cron.conf AND /etc/yum/yum-cron-hourly.conf.
Note that in contrast to CentOS 6.x, by default yum-cron only download updates once a day and doesn’t apply them. change to:
apply_updates = yes
In /etc/yum/yum-cron.conf if you wish to. make note that you can now define hourly updates in the /etc/yum/yum-cron-hourly.conf file.