Restrict Crontab job between a particular interval

*爱你&永不变心* 提交于 2019-12-14 01:33:44

问题


I have a ruby file and I need to run it once in every 3 hours. This code works fine:

27 */3 * * * /path/to/ruby -rubygems /path/to/ruby_file.rb

And I don't want this file to run between midnight 12.00 to morning 8.00

How can I set it?


回答1:


27 9-23/3 * * * should work on most modern variants of Unix.




回答2:


27 9-23/3 * * * /path/to/ruby -rubygems /path/to/ruby_file.rb

should do the trick.

A good summary of it all can be found in this wikipedia article.




回答3:


*/15    10-20   *       *       *       /usr/bin/php /tmp/myscript.php

*/6     6-9,21-23,0-2   *       *       *       /usr/bin/php /tmp/myscript.php

More complex cron for you my friend. Notice: cron do not jump over 23-0




回答4:


2-10/4 like 2,8 or 2,6,10 ?

I think the seconds



来源:https://stackoverflow.com/questions/6248662/restrict-crontab-job-between-a-particular-interval

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