Setting cron only from morning to evening

I need to run a daily cron.

Cron’s working hours should be 11:00 in the morning until 7:00 in the evening.

At this time, cron should start every 15 minutes daily.

Does the same thing after a night in cron should work every hour?

Is this possible using the linux cron scheduling type.

Or I need to manage this from any scripting language.

+6
source share
2 answers
*/15 11-18 * * * statement/to/run 0 0-10,19-23 * * * statement/to/run 

Must do what you need.

* / 15 or 0,15,30,45 will do the same and work every 15 minutes.

You need to split it into two entries, since you want it to work differently at different times of the day.

+7
source

I don’t think you can do this with one rule, so you will need to use three, for example:

 0 00-10 * * * /path/to/cron/job 0,15,30,45 11-18 * * * /path/to/cron/job 0 19-23 * * * /path/to/cron/job 

The first rule is processed from 00:00 to 10:00, the second from 11:00 to 18:45 and from 19:00 to 23:00 to complete the set.

Obviously, you can adjust the offsets within an hour, when everything will be done by changing the values ​​in the first column.

+5
source

All Articles