
(Picture from meds.queensu.ca)
On any Linux there are two commands for scheduling at and cron. Programs scheduled by command at will be executed once at a defined time. With crontab it is possible to define a command that will be executed periodicly.
To make sure you can use crontab check if there is /etc/cron.allow file and if it exsists check for your username there. If you use a Debian based Linux you don’t need to worry, you’re may use it by default.
Crontab saves configuration in a simple text file and by entering crontab -e you can edit it in terminal. The syntax for is simple:
time command
Time is construced like this
m h dom mon dow
- m is for minute
- h is hour
- dom is day of month
- mon is month
- dof is day of week
So a simple example would be:
0 0 2 2 1 dd if=/dev/sdb of=./backup
This will backup a device at /dev/sdb at midnight 2nd February and this command will be executed once, to make it run repetitionly, you will need to put asterisk (*) in the place needed. For example if you want to run this command at midnight every day, put asterisk(*) in every place except m and h:
0 0 * * * dd if=/dev/sdb of=./backup
For weekly repetition (every monday):
0 0 * * 0 dd if=/dev/sdb of=./backup
You can also define a range using a hyphen (-) to define a range and a comma for multiple values:
0 12 * * 0-4 mpeg321 ./dont_worry_be_happy.mp3
0 10,16 * * * mailprogram
The first command plays “Don’t worry be happy” every day from monday to friday at 12 and second one checks your mail twice a day.
And for the end the most interesting, to schedule GUI apps with crontab use: export DISPLAY=:0 && app-name.
Related Posts
No related posts.











Just remember: you’re not a ‘dummy,’ no matter what those computer books claim. The real dummies are the people who–though technically expert–couldn’t design hardware and software that’s usable by normal consumers if their lives depended upon it.



I always cheat and use the cron GUI – Kcron
(kde4 it is is system settings / task scheduler), I find it far easier as you construct the tasks in Enlgish.., you can then look to what the correct cron syntax to use )
- As usual gnome's equivalent lacks the features a KDE app.
I also like to use gui apps more, there is no reason to make my life harder, but crontab is very easy.