Saturday, April 28, 2012

Cron

cron is a time-based job scheduler in Unix-like computer operating systems. cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates



EntryDescriptionEquivalent To
@yearly (or @annually)Run once a year, midnight, Jan. 1st0 0 1 1 *
@monthlyRun once a month, midnight, first of month0 0 1 * *
@weeklyRun once a week, midnight on Sunday0 0 * * 0
@dailyRun once a day, midnight0 0 * * *
@hourlyRun once an hour, beginning of hour0 * * * *
@rebootRun at startup


*    *    *    *    *  command to be executed
┬    ┬    ┬    ┬    ┬
│    │    │    │    │
│    │    │    │    │
│    │    │    │    └───── day of week (0 - 6) (0 is Sunday, or use names)
│    │    │    └────────── month (1 - 12)
│    │    └─────────────── day of month (1 - 31)
│    └──────────────────── hour (0 - 23)
└───────────────────────── min (0 - 59)
crontab - l = list
crontab -e = edit
crontab -r = removes crontab directory
crontab -u username -l

So in terminal print ‘Hello’ every 5 minutes..

# MIN   HOUR   MDAY  MON  DOW   COMMAND 
   */5     *      *     *    *    echo 'Hello' 

No comments:

Post a Comment