问题
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