Cron

Created Tuesday 03 December 2013

http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/
http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/
http://www.unixgeeks.org/security/newbie/unix/cron-1.html

http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/

* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

  1. The asterisk (*****) : This operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to every hour or an asterisk in the month field would be equivalent to every month.
  2. The comma (,) : This operator specifies a list of values, for example: "1,5,10,15,20, 25".
  3. The dash (-) : This operator specifies a range of values, for example: "5-15" days , which is equivalent to typing "5,6,7,8,9,....,13,14,15" using the comma operator.
  4. The separator (/) : This operator specifies a step value, for example: "0-23/" can be used in the hours field to specify command execution every other hour. Steps are also permitted after an asterisk, so if you want to say every two hours, just use */2.

  1. Edit crontab file:
    1. crontab -e
  2. List all cron jobs:
    1. crontab -l
    2. crontab -u username -l
  3. Restart cron:
    1. service cron stop
    2. service cron start
    3. service cron restart
  4. Log:
    1. /var/log/syslog
  5. List crontabs for all users
    1. awk -F: '{print $1}' /etc/passwd | xargs -l1 crontab -lu 2>/dev/null



Backlinks: