Skip to content

Automatic Updates : Ubuntu (all versions)

Below is a quick hack to have your Ubuntu machine automagically update for you at a pre-specified time. This includes the “update”, “upgrade”, “dist-upgrade” and “autoclean” commands. The scheduling is taken care of by cron, our trusty always-on-time friend.

sudo crontab -e

It is important that you use sudo at this point. The command will need super-user priveleges so the cron listing needs to be setup as the root user.

0 0 * * * aptitude -y update && aptitude -y upgrade && aptitude -y dist-upgrade && aptitude -y autoclean

The above line represents the listing put into the crontab file. Here is a quick explanation of the five fields you can specify for the date and time. (The above executes daily at midnight)

minute - hour - day of month - month - day of week

After you have specified the appropriate time and date for your system simply save the file and your system will now automagically upgrade at the time specified. These upgrades include regular updates, kernel updates, security updates, etc. Also, the “autoclean” command removes old packages from your system after they are no longer needed.

Of course, if you prefer not to have cron take care of everything (if you’d still like to be somewhat hands-on) you could simply run the command in a single line:

sudo aptitude -y update && sudo aptitude -y upgrade && sudo aptitude -y dist-upgrade && sudo aptitude autoclean

technorati tags:, , , , , , , ,

If this site has been useful, please consider participating in the Fundraiser.

Other Points of Interest

  • No Related Post