You can use yum-updatesd service provided with CentOS / RHEL servers. However, this service provides a few overheads. You can create daily or weekly updates with the following shell script. Create
- /etc/cron.daily/yumupdate.sh to apply updates one a day.
- /etc/cron.weekly/yumupdate.sh to apply updates once a week.
Sample shell script to update system
A shell script that instructs yum to update any packages it finds via cron:#!/bin/bash(Code listing -01: /etc/cron.daily/yumupdate.sh)
YUM=/usr/bin/yum
$YUM -y -R 120 -d 0 -e 0 update yum
$YUM -y -R 10 -e 0 -d 0 update
Where,
- First command will update yum itself and next will apply system updates.
- -R 120 : Sets the maximum amount of time yum will wait before performing a command
- -e 0 : Sets the error level to 0 (range 0 - 10). 0 means print only critical errors about which you must be told. -d 0 : Sets the debugging level to 0 - turns up or down the amount of things that are printed. (range: 0 - 10).
- -y : Assume yes; assume that the answer to any question which would be asked is yes.
# chmod +x /etc/cron.daily/yumupdate.sh
No comments:
Post a Comment