Regularly updating operating systems is now an essential task. And the operating system at the base of NetEye (CentOS 7) must be regularly updated.
But I still find many customers who for lack of time forget these updates and ask me if it’s possible to get an automatic report of them.
And here I found a very useful utility called yum-cron which is just right for us!
From its man page:
yum-cron is an alternate interface to yum that is optimized to be convenient to call from cron. It provides methods to keep repository metadata up to date, and to check for, download, and apply updates. Rather than accepting many different command line arguments, the different functions of yum-cron can be accessed through config files.
With this utility it is possible both to download and perform updates, but I always suggest that customers use it ONLY for downloading and for notification of the availability of updates and then proceed manually.
The installation steps are quite easy:
# yum install yum-cron # systemctl start yum-cron # systemctl enable yum-cron
Now we can edit the yum-cron configuration file:
# cp -a /etc/yum/yum-cron.conf /etc/yum/yum-cron.conf.orig # vim /etc/yum/yum-cron.conf
In the [commands] section we can define the types of packages we want to be updated, enable messages and downloads, and it’s here that I suggest you set “no” for automatic applying updates:
[commands] update_cmd = yum update --enablerepo=neteye update_messages = yes download_updates = yes apply_updates = no random_sleep = 360
In the following sections we can define how to send a notification via email:
[emitters] system_name = neteye4.mydomain.com emit_via = email output_width = 80 [email] email_from = email@example.com email_to = firstname.lastname@example.org
You can grep /var/log/cron to check if cron jobs associated with yum have been executed:
[root@neteye4 ~]# grep yum /var/log/cron Dec 18 14:01:01 neteye4 run-parts(/etc/cron.hourly): starting 0yum-hourly.cron Dec 18 14:04:53 neteye4 run-parts(/etc/cron.hourly): finished 0yum-hourly.cron Dec 18 15:01:01 neteye4 run-parts(/etc/cron.hourly): starting 0yum-hourly.cron Dec 18 15:01:05 neteye4 run-parts(/etc/cron.hourly): finished 0yum-hourly.cron
That’s all! From now on you will be notified about any available updates via email.