Getting a cPanel/WHM Server to Email Pending YUM Updates

JeffTechnical Articles & Notes

I used to try to remember every day to log in to my server and check if there were any manual updates needed (these can be kernel updates etc etc) by running this command:

yum check-update

This outputs the list of mirrors and then a list of any packages with updates available for them.

Problem is it’s a bit of a pain to have to log in, and then manually run that command every day.

A very very simple solution is to have that command run automatically every day and email the result to your choice of email address. Fortunately it’s very very easy to do this.

All you need to do is locate and edit the file:

/etc/crontab

Add this line at the top (or edit it) so that the output from scheduled tasks (known as cron tasks) is emailed to you:

MAILTO=you@yourdomain.com

And then at the bottom of the same file, add a new ‘cron’ job as follows:

# Check for available updates on yum. Output emailed to address above
00 09 * * * root yum check-update

Now save /etc/crontab, and you’re done.

This is set to run every day at 09:00, and because the output of all ‘cron’ jobs is now set to email to you, you will receive a daily notification of any pending server updates.