Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Given a crontab expression like "0 0/15 11-15 ? * MON-FRI", how is that parsed?

I am correct in assuming the 11-15 does not mean "between 11 and 15" but "when the hour is 11-15, inclusive" - i.e. the expression will trigger every 15 minutes starting at 11:00 and ending at 15:45? Or will it end at 14:45? Or maybe 15:00?

share|improve this question
    
The expression is actually a version of a cron expression used by the Java Quartz Scheduler CronTrigger. See the comments for the accepted answer below, sorry if this is confusing. –  PapaFreud Nov 8 '11 at 10:30
add comment

1 Answer

up vote 5 down vote accepted

You have too many fields in your example.

The available fields in a cron job are:

`min hour mday month wday command+args`

The command in your example line would run on:

  • The zero minute
  • every 15 hours, starting at midnight (so midnight and 3pm)
  • on the 11th/12th/13th/14th/15th of the month,
  • invalid month field of ?
  • every day of the week
  • Run the command MON-FRI

Unless, in your specific version of cron, ? is allowed as a non-greedy wildcard for the month field, in which case, it might match single-digit month numbers, or January -> September.

share|improve this answer
    
Right you are. I'm not actually setting up a crontab but using a Java Quartz Scheduler CronTrigger but posted it here instead from at stackoverflow after seeing people be told to ask crontab-related questions here. Sorry. The CronTrigger has a fields for seconds too -- "seconds minutes hours dayOfMonth month DayOfWeek [year]". I'm posting this over at SO instead. –  PapaFreud Nov 7 '11 at 14:57
    
ah. that extra field makes all the difference. your application would then run, every 15 minutes, on the zero second, from 11:00 to 15:45, every mon-friday. –  Tim Kennedy Nov 7 '11 at 15:30
    
Yes, I've left it running and it did stop at 15:45. Thanks! –  PapaFreud Nov 7 '11 at 16:03
add comment

Your Answer

 
discard

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.