Scheduling a program using the crontab file
From the internet, and slightly adjusted for a linux system… [http://www.kalab.com/freeware/cron/cron.htm]
The Crontab file
Each line of CRONTAB has the following structure:
Position: Â Â Â Values:
Minute    0-59
Hour    0-23
Day    1-31
Month    1-12
Day of week    0-6 (0=Sunday, 1=Monday, …, 6=Saturday)
Instead of minute, hour, day, month or day of week it’s also possible to specify a *. A * represents all possible values for that position (e.g. a * on 2nd position is the same as specifying all the possible values for hour)
It’s also possible to specify several values separated by commas: e.g. if you want a command to be executed every 10th minute so you can specify 0,10,20,30,40,50 for minute. A range of values can be specified with a -: e.g. value 0-12 for hour -> every hour a.m.
Comments
Every line not starting with a number is treated as a comment.
Examples
execute a command every minute
* * * * * /somecommand
execute the program every hour
0 * * * * /somecommand
every day at 0.30 p.m.
30 12 * * * /somecommand
every tuesday at midnight
0 0 * * 3 /somecommand
1st of every month at 2.45 p.m.
45 14 1 * * /somecommand
every half hour
0,30 * * * * /somecommand
every hour (a.m.) only on weekdays
0 0-12 * * 1-5 /somecommand
Posted: May 4th, 2008 under Linux.
Comments: none
Write a comment