Automatic upgrades on Ubuntu with apt and cron

Inked by Fran Dieguez

If you want to get automatic upgrades of your personal repositories I haven’t find a way to get managed with unattended-upgrades so I have done the next workarround.

This way is to use apt-get and crontab together, so open your crontab editor:

sudo crontab -e

And type the next line to execute our upgrade every night at 1AM:

0 1 * * * (/usr/bin/aptitude -y update && /usr/bin/aptitude -y safe-upgrade) 2>&1 >> /var/log/auto_update.log

Save and exit your editor, and you are all set! You could check the logfile: /var/log/auto_update.log every once in a while to see if everything is still running smoothly.

Note: If you have a solution to get to work unattended-upgrades package with custom repositories please fill a comment below.