Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cron oddity or I'm misled

Status
Not open for further replies.

BPetro

Programmer
Oct 1, 2002
59
US
Doesn't cron "AND" the logic for all the crontab fields until all are true to run a command? I thought so but appears I'm wrong. I set a job up that emails me to show it ran (just to see if I could get at this strange repeating run request) - and its running when I think it shouldn't... some details... by the following, I'm trying to get at the Thursday that falls after the first Sunday of the month. I added it to crontab yesterday But it ran last night (on WED. the 11th) instead of waiting until next month on the 10th which will be the Thursday after the first Sunday in July.

0 22 5-11 * 4 /home/bap/didCronRun.sh THURS_AFTER_FIRST_SUN

So - I thought cron ANDs -- Am I wrong? Does it OR?
 
It ran on Thursday (4) on every month (*) from the day of 5-11 (11 was yesterday). You can't specify which Sunday. Maybe that is where you are thinking your problem is.
 
Sorry - guess I wasn't clear. Let me try to re-describe this. It was marked in crontab to run on Thursday (4) -- but it ran on Wed. WHY? Again, forget Sunday - its supposed to run on Thursday and telling it 5-11 SHOULD tell it WHICH Thursday of the month to run on.

Again, does anyone know if cron logic is all AND'd together? If so, are there reports for any bugs in cron? If not, which portion of a cron is AND'd and which portion is OR'd?

My thinking was: cron should have said - "I'm not going to run this job until minutes = 00, hrs = 22, day of month is between 5-11 and day of week = 4". But instead it ran when the first 3 matched but day of week was = 3 which DIDN'T match.

That makes me ask - what happened to the AND which I thought was the entire logic in cron ??? Am I wrong about AND or is there a bug here?

THANKS!

 
You are wrong in the assumption, there is an exception:

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 (ie, 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.

More details here: faq54-2044

IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
MS Certified Windblows Rebooter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top