Keep CentOS up-to-date automatically

CentOS can automatically be updated with latest fixes. With the following settings yum updates the system to latest level even if you are away for any reason. This might prevent a hack due to unsecure packages installed on your system.
But you need to be aware that this might also break your system while you are away! So you need to consider if uptime or security is your focus.

You need to install yum-cron package to achieve this:

yum install yum-cron

This will configure a daily cronjob /etc/cron.daily/yum.cron.
If you cehck this file you will find the following comment at the top:

# Only run if this flag file is set (by /etc/rc.d/init.d/yum-cron)

So just do it:

/etc/rc.d/init.d/yum-cron start
chkconfig yum-cron on

The service can either be configured just to download latest fixes or to install these fixes. This is done in the file /etc/sysconfig/yum-cron

# 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