I'm trying to:
- run job A the first day of the month: 0 0 1 * *
- run job B the other days of the month: 0 0 2-31 * ?
Vixie cron on Ubuntu 14.02 LTS refuses the second syntax, though it seems valid according to Wikipedia and official specs:
"crontab", The Open Group Base Specifications Issue 7 — IEEE Std 1003.1, 2013 Edition, The Open Group, 2013, retrieved May 18, 2015
According to references above, the syntax 0 0 2-31 * *
would run the job every day of the month as third and fifth fields are treated as OR clauses of the run condition.
You should be using a
*
, not a?
(which is invalid).The Wikipedia page notes that the
?
is a nonstandard extension used only by nnCron, which you aren't using.In any case, if the day of week is set to
*
and the day of month is specified, then the day of week is ignored. The IEEE 1003.1 spec you reference actually states this, explaining how these fields interact:So the correct format is exactly the logical one:
You could use date:
If your crond doesn't allow you to specify the different dates, wrap a small shell script around your scripts.
Run the script every day and let it decide which of your scripts to run.