View Full Version : HOWTO: Using Cron to Update System

October 29th, 2004, 12:18 PM
Here is a quick and hopefully informative way to use cron to update your system.

Cron is a scheduling program used often in many *nix distro to run automated tasks if your like me and are coming from windows it would equate to task scheduler in windows.

cron's format is
minute: hour: day of the month: day of the week: command:

30 22 * * 0 apt-get update && apt-get -y dist-upgrade -t warty-security

The above example would tell cron to run a check for security updates every sunday at 10:30 pm

*suggested by jdong*

30 22 * * 0 apt-get update

This job would tell cron to update but you would be required to upgrade manually

To make a cron job yourself type in an open console type:
1) crontab -e
2) press the i key to insert commands
3) input your commands using the above guide
4) press esc and then press :wq! to exit and save changes

hopefully if all goes well you should now have setup cron to run a specific task at its appointed time

if your not comfortable inputing the commands yourself there is a site that goes into more detail and has a tool to set up your commands for you.


I hope this helps


* updated to include sugestions by jdong

October 29th, 2004, 12:43 PM
Although I won't use it because I perfer to do it myself. I even did it myself when running windows. This is a very good guide.

October 30th, 2004, 01:27 PM
I don't think it's correct. apt-get dist-upgrade will just sit at a Y/n prompt indefinitely. Every night you run it, you'll get a new one...... You need apt-get -y dist-upgrade -t warty-security.

If you don't like for updates to apply without you knowing, you can always just set a cron job for apt-get update so you'll always have up to date sources.

January 11th, 2006, 03:59 PM
Although apt-get does have the '-y' option, many other commands do not. In that case, you can simply say:
yes 'y' | your -command -here and it will answer all questions with 'y'.

October 10th, 2006, 10:16 PM
How can I extend this to dial up, say every Saturday night at midnight, do the update, then hangup?

I found the answer at this thread:

This thread has an elaborate script: