setup cron from morning to evening only [closed]

只谈情不闲聊 提交于 2020-01-22 19:53:50

问题


I have to run daily cron.

Cron must running time will be morning 11 AM to evening 7 PM.

In this given time cron must run at every 15 mins daily.

same thing after in night cron must run at every hour?

Is this possible with linux cron scheduling type.

Or i have to manage this from any scripting language.


回答1:


*/15 11-18 * * * statement/to/run
0 0-10,19-23 * * * statement/to/run

Should do what you need.

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

You'll need to break it into two entries since you want it to run differently during different times of day.




回答2:


I don't think you can do this with a single rule, so you will need to use three, like this:

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 handles 00:00 to 10:00, the second 11:00 to 18:45 and the third 19:00 to 23:00 to complete the set.

Obviously you can adjust the offsets within the hour when things run by changing the values in the first column.



来源:https://stackoverflow.com/questions/13136706/setup-cron-from-morning-to-evening-only

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!