I installed Ubuntu on my parents’ computer a few years ago. They are approaching 60 and they aren’t very computer savvy. I keep telling them to click that orange/red icon in the top right corner to install updates, but they never do. So when I visit every few months I have to update hundreds of packages. However, I recently set up automatic updates using crontab. Here’s how I did it.
Create a cron job file as root: sudo crontab -e
Add the following line: 0 5 * * * (PATH=/usr/sbin:/usr/bin:/sbin:/bin && intro=”\n***Beginning auto-update on “`date`”\n\n” && echo -e $intro >> /var/log/auto_update.log && apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade && apt-get -y clean) 2>&1 >> /var/log/auto_update.log
Looks like a mess, doesn’t it? Here’s what it does: every day at 5 am, apt-get updates the package list, upgrades any packages that need upgrading, upgrades the entire system if a new version of Ubuntu is available (if you don’t want to do this, remove the text in red), and cleans the system of residual packages; and all the changes are recorded in a log file located at /var/log/auto_update.log.
All I have to do is check that file to make sure it’s working and there aren’t any errors, which I can do via SSH or the Remote Desktop Viewer. I could even have the changes emailed to me every day, but I think that’s overkill.
Also, don’t forget to turn off updates in Synaptic Package Manager. You don’t need both update systems running.