Linux has the ability to run a shell script whenever desired. We use one to automatically install updates and if necessary reboot the system.

sudo apt-get needrestart

adding this program makes it easier to test for reboot required due to a kernel update etc.

needrestart -k

will reboot if the system is prompting for a reboot

so to mechanize updates:

sudo nano update

then add these lines to the update file

sudo apt-get update
sudo apt-get upgrade
needrestart -k

now to schedule we need to add this to the crontable

sudo crontab -e

add this line to the bottom

29 0 * * * bash /home/myaccount/update

this will allow you to add your updates file. make sure you add the fill path so that it will be able to find it

now the system will be updated automatically and edits to the original update can be done as needed

permission is needed for the cron task so making it world readable is easy, chron needs read and execute while the owner has total read/writecontrol

sudo chmod 755 update


minute hour day month day-of-week command-line-to-execute

  • minute (from 0 to 59)
  • hour (from 0 to 23)
  • day of month (from 1 to 31)
  • month (from 1 to 12)
  • day of week (from 0 to 6) (0=Sunday)

0 */2 * * * // is every other hour etc

delimiters are the space, the comma and / are special modifiers.