Showing posts from May, 2014

Scheduled updates with cron job

If you want to install updates on a server you may want it done at night when users are sleeping (hopefully). That is not that difficult with a shell script and a cron job . The shell script takes care of calling all the update commands and the cron job schedules the executing and log the output to a custom log file. First the shell script: #!/bin/sh echo "\nUpdate on: $(date)\n" echo 'Update the packages list\n' sudo /usr/bin/apt-get update >> /dev/null 2>&1 echo '\nUpgrade to latest package version\n' sudo /usr/bin/apt-get upgrade --yes echo '\nUpgrade the distribution\n' sudo apt-get dist-upgrade --yes echo '\nCleanup\n' sudo /usr/bin/apt-get autoremove --yes sudo /usr/bin/apt-get autoclean --yes sudo /usr/bin/apt-get clean --yes # # The End # The script executes after all a bit of cleanup. Put the "" script in a folder and make it executable: $ chmod +x Now the cron job rule: open