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?
27 9-23/3 * * * should work on most modern variants of Unix.
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.
*/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
2-10/4 like 2,8 or 2,6,10 ?
I think the seconds
Related
I want to make run fron every 15 minutes,it can be achieve by */15 * * * *.
But It can be possible it runs only between 7am to 7pm at morning?
You can use */15 7-19 * * * to run a cronjob between 7am and 7pm.
I think that */15 7-19 * * * should work.
If you want to have it from 7pm to 7am then I think you have to add two cron jobs
*/15 0-7 * * *
*/15 17-23 * * *
Try this.
15 7,8,9,10,11,12,13,14,15,16,17,18,19 * * * /your file path to execute
I have set crontab on every 24 hrs should run a single php command, instead it runs the command like 20+ times a day. It doesn't work as it should. Is it really wrong?
* */12 * * * php /var/www/mything.php
I added this on new crontab line? Is the line correct?
0 */12 * * * php /var/www/mything.php
should run the command every 12 hours (0 and 12 o'clock)
0 12 * * * php /var/www/mything.php
should run the command at 12 o'clock every day
For example I want to run job every 6 minutes between;
16:34 - 18:45
So it must be running on 16:34, 16:40, 16:46 etc. to 18:40.
When I write
34-45 16-18 * * *
It only works between 16:34-16:45 and 18:34-18:45. But I don't want this one.
Is it possible to make this?
Thank you
Hm, where in your cron line is the "every 6 minutes" part? Also, why would your cron go to 18:40, wouldn't 18:42 be the last time you want it to run? Let me know if I'm not understanding the question correctly.
Anyway though, not sure if it's possible in one cron line, but you could always do something like:
34/6 16 * * *
*/6 17 * * *
0,6,12,18,24,30,36,42 18 * * *
Edit: Or, if you have control and are able to edit the file/executable your cron is running you could do:
*/6 16-18 * * * /path/to/myScript
And then at the very beginning of myScript:
if time < 16:34 or time > 18:45:
exit # kill script
I have a php script which crontab executes every 30 minutes, during off-peak hours around 2-7am I don't get much traffic and so I wish to not run the script during these hours.
I'm not sure how to make a cronjob that will do this as I would find it hard to test.
The cronjob I have at the moment looks like this
*/30 * * * * /usr/bin/php /var/www/update/inv.php
*/30 0-1,8-23 * * * /usr/bin/php /var/www/update/inv.php
the range is inclusive, so 0-1 will do 00:30, 01:30, then 8-23 will do 0830 to 2330
ref: http://team.macnn.com/drafts/crontab_defs.html
You can restrict the hours you want the job to run.
*/30 0,1,7-23 * * * /usr/bin/php /var/www/update/inv.php
The times will be every 30 minutes until 0130. It won't run at 0200. The next run will be at 0700 and then every 30 minutes.
There's quite a good article here on how to set up the cron:
http://en.wikipedia.org/wiki/Cron
I want to run a php script every 10 minutes, between the hours of 9:30AM - 4:00PM
I googled before asking, and didn't have any success.
Anyone know how to do this? Or point me in the right direction?
Thank you
Try the following three lines in crontab
0,10,20,30,40,50 10-15 * * * # Every 10 minutes for the hours 10am - 3pm
0 16 * * * # 4pm
30,40,50 9 * * * # and 9:30, 9:40, 9:50
Run it from cron in every 10 minutes, check th date in PHP do nothing if it's outside the range.
*/10 * * * * /usr/bin/php /path/to/your/script.php