Alex
Alex

Reputation: 38509

Cron Expression - Every 5 seconds between 7am and 8pm...?

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?

Upvotes: 5

Views: 15435

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368191

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, the smallest unit that cron can be configured with is 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.

Upvotes: 3

Related Questions