Mar
20
2009

Unix / Linux Job Automation “crontab” Tips

Below are the tips I keep in mind with respect to crontab file format / configuration on Linux and Unix systems.

  • crontab file line layout is:
minute hour day month dayofweek command

  • For any one of columns you can use a “*” to match every instance
e.g. * for hour column means every hour (at the exact specified minutes)

  • For any one of columns you can use more than one value comma separated
e.g. 1,3,25 is 1,3 or 25 matched

  • For any one of columns you can use range of values with hyphen “-”
e.g. 4-7 is 4,5,6,7

  • For any one of columns you can define steps.
e.g. */3 in for “day” means once in every three days

  • For any one of columns you can combine ranges and values
e.g. 1-3,7,9-12 is actually 1,2,3,7,9,10,11,12

  • For any one of “minute hour day month dayofweek” you can define steps in custom ranges
e.g. 2-11/3 is actually 2,5,8,11

For more information you can check the manpages below:

  • man crontab ~ for the command usage
  • man 5 crontab ~ for the file format & configuration
Share
Written by in: linux,sysadm | Tweet This

No Comments »

RSS feed for comments on this post. TrackBack URL


Leave a Reply

Powered by WordPress | Theme: Aeros 2.0 by TheBuckmaker.com