We had a problem recently where a job was scheduled on cron something like this:
25 14 23 09 1 /bin/date > /usr/users/oracle/andrew/date.log 2>&1
This should run at 1425 hours but will it run just on Monday 23rd September or will it run every Monday? I didn’t know as I only ever specify the day and month OR the day of the week, never both. I waited until the following time:
Tru64 > date
Mon Sep 30 14:20:40 BST 2013
Tru64 >
I added the line above to the cron file then waited until the following time:
Tru64 > date
Mon Sep 30 14:27:32 BST 2013
Tru64 >
The job had run as the output file had been updated with the run time so it seems that, on Tru64 at least, it will run every Monday irrespective of the day and month:
Tru64 > pwd
/usr/users/oracle/andrew
Tru64 > cat date.log
Mon Sep 30 14:25:00 BST 2013
Tru64 >
If you want it to run only on 23rd September, you should schedule it like this:
25 14 23 09 * /bin/date > /usr/users/oracle/andrew/date.log 2>&1
I moved to a Solaris machine and added the line below to the cron file.
16 15 30 09 2 /usr/bin/date > /export/home/oracle/andrew/date.log 2>&1
This should run at 1516 hours but will it run just on Tuesday 30th September or will it run every 30th September? I waited until the following time:
Solaris > date
Monday, 30 September 2013 15:16:22 BST
Solaris >
The job had run as the output file had been updated with the run time so it seems that, on Solaris too, it will run every 30th September irrespective of the day of the week:
Solaris > pwd
/export/home/oracle/andrew
Solaris > cat date.log
Mon Sep 30 15:16:00 BST 2013
Solaris >
If you want it to run only on Tuesdays, you should schedule it like this:
16 15 * * 2 /usr/bin/date > /export/home/oracle/andrew/date.log 2>&1
To summarise, if you schedule a job on cron and specify a day and month AND a day of the week, it will run when EITHER condition is satisfied, it does not need to wait until both conditions are satisfied.