views:

541

answers:

2

I have the following Cron expression i use with Quartz.net:

0/5 * * ? * MON-FRI

Basically, every 5 seconds, Mondays - Fridays.

How can I modify this so it only runs between 7am and 8pm on those days?

A: 

Take a look what Cron is: http://en.wikipedia.org/wiki/Cron

ZeissS
take a look what Quartz.net is - http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html
alex
I know Crontab != Quartz.net but they use the (mostly) the same notation for the timing stuff.
ZeissS
+1  A: 

This entry would be for every five minutes between 7:00 and 7:55 on Mon to Fri:

0/5 7  * * 1-5    who /usr/bin/what

as user who running /usr/bin/what. To my knowledge, cron does look inside a minute. But you could start something at 7:00am on Mon to Fri which then itself would

do { 
   work 
   sleep(5)      // or sleep(4) or whichever, depending on length of work task
} while (not yet 08:00am)

which is not that hard to put together.

Dirk Eddelbuettel
sorry, i should of clarified-I'm using Quartz.net - it has CronExpression support:http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html
alex
Thanks for your help - In the end I came up with:0 0/5 7-20 ? * MON-FRIWhich is every 5 minutes (a little diff. from my initial request) but this works.
alex
Oh, right, I missed the 8pm. If you want to run the last one at 20:55 then 7-20 for the hour field is indeed correct.
Dirk Eddelbuettel