Cron Expression - Every 5 seconds between 7 AM and 8 PM ...?

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

0/5 * *? * MON-FRI

In principle, every 5 seconds, on Mondays - Fridays.

How can I change this, so it only works from 7 AM to 8 PM these days?

+4
source share
1 answer

This entry will be for every five minutes between 7:00 and 7:55 in Mon-Fri:

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

how the user who works /usr/bin/what . As far as I know, the smallest unit with which you can configure cron is a minute.

But you could start something at 7:00 a.m. on Mon-Fri, which then would be

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

which is not so difficult to assemble.

+2
source

Source: https://habr.com/ru/post/1299972/


All Articles