Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

I have a question. We have a cron job that executed on the 15th of this month:

min hr day month day_of_week
35  13 15  6     6

However, it executed again on June 22nd (which was the 6th day of the week). Would the day_of_week take precedence over day & month that was already set before?

share|improve this question
up vote 3 down vote accepted

While normally the job is executed when the time/date specification fields all match the current time and date, there is one exception: if both "day of month" and "day of week" are restricted (not "*"), then either the "day of month" field (3) or the "day of week" field (5) must match the current day

So it happens only in June, at 13:35. Additionally it needs to be EITHER the 15th of June, or the 6th day of the week. Both at once will work too.

Running man 5 crontab will give you some additional information, they recommend you use test to specify both a specific date and restrict the weekday :

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. One can, however, achieve the desired result by adding a test to the command (see the last example in EXAMPLE CRON FILE below).


# Run on every second Saturday of the month
0 4 8-14 * *    test $(date +\%u) -eq 6 && echo "2nd Saturday"
share|improve this answer
So you think give the setup, repeat of the cron is possible? Since the day of the month & day of the week are both restricted, it would work on either of the dates. – brooding_goat Jun 24 '13 at 21:57
Yes. It will run again on 29.06.2013 13:35, because that will meet the requirements of minute, hour, month, and day of the week. – Squeezy Jun 24 '13 at 22:03
thanks. So how do we say that run only on 15th of the month. Do we put * for the day of the week? – brooding_goat Jun 24 '13 at 22:06
Yes. If you want to run it on the 15th of ANY month, not only June, also put * for month. – Squeezy Jun 24 '13 at 22:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .