Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Crontable parameters seem to function as 'ands' conditions. So the example

0 9-5 * * 1-5

Runs when the conditions are met "minute is zero AND hour is between 9 and 5 AND day is between monday and friday".

What I'd like is an 'or' function, so I can say "run monday to friday OR the 8th day of the month". Does such a thing exist?

I realise you could add two entries, but with lots of entries it adds something to forget.

share|improve this question
up vote 2 down vote accepted

I was gonna say: use , (comma). From man 5 crontab:

Lists are allowed.
A list is a set of numbers  (or  ranges)  separated  by  commas.
Examples:  "1,2,5,9","0-4,8-12".

But your case is slightly more complicated, and you can take advantage of this feature:

Note: The day of  a command's execution can be specified by two fields day
of month, and day of week. If both fields are restricted (i.e., aren't *),
the command will be run when either  field matches the current time.
For example, "30  4  1,15  *  5" would cause a command to be run at 4:30 am
on the 1st and 15th of each month, plus every Friday.

So in your case, you can write 0 9-5 8 * 1-5. That would run your command every 8th of the month and every day from Monday to Friday.

Another solution is to use a test (man bash, section CONDITIONAL EXPRESSIONS, and man date):

# Run on every second Saturday of the month:
   0 4 8-14 * *    test $(date +%u) -eq 6 && echo "2nd Saturday"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.