Crontab Syntax

Posted on: 2016/02/17 Tags: cron

One thing I still cannot remember after YEARS of usage is the scheduling syntax for cronjobs. To help with this I usually paste the following into each crontab:

# m h dom mon dow cmd
  • m: minute
  • h: hour
  • dom: day of month
  • mon: month
  • dow: day of week
  • cmd: command to execute


Instead of fixed numbers, you can also use expressions. You probably already know the asterisk (*) to match every value, but there are more:

  • use commas to specify a list of values, eg. 2,5,7
  • use hyphens to specify a range of values, eg. 5-9
  • use slashes to specify steps, eg. */2 in the minute field to execute a command every other minute. (note: */2 in the minute field means execute command on every minute divisible by 2)