Saturday, May 1, 2010

Crontab file syntax

Crontab is a file which contains the schedule of cron entries to be run and at specified times.
*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)
Examples:
# 00:30 on 1st of Jan, June & Dec
30    0   1        1,6,12  *
# 8.00 PM every weekday (Mon-Fri) only in Oct 
0     20  *        10      1-5  
# Midnight on 1st ,10th & 15th of month
0     0   1,10,15  *       *
# 12.05,12.10 every Monday & on 10th of every month 
5,10  0   10       *       1  
# Every 2 hours, at 2am, 4am, 6am, and so on
0     */2 *        *       *
You can simply drop your cron schedule file into /etc/cron.d/. Read more about cron here.

No comments :

Post a Comment