Currently I have
*/5 * * * * (job) &
My goal is to run a crontab each 5 minutes after it finished executing, not every 5 minutes.
So what I want is
---- wait 5 minutes ---- run job ---- job finished ---- wait 5 minutes .... etc.
but currently it seems like
---- wait 5 minutes ---- run job ---- if 5 minutes passed run job again even if the previous job wasn't finished ---- wait 5 minutes .... etc.
which results in many concurrent threads that serve no purpose and make the system freeze.
Related
I would like to run the cron job every 20 minutes between 9 AM and 11 PM and once an hour after 11 PM until 9 AM.
cron job settings
I created 2 cron jobs for the same script to achieve my goal. Did I do it correctly?
Thank you.
Not really. There are two issues:
you run the script also on 23:20 and 23:40
you run the script twice from 09:00 till 23:00 every hour.
The way to do it is:
*/20 9-22 * * * command
0 0-8,23 * * * command
You can validate this using crontab guru
despite reading many things on cron I am not able to achieve what I am looking for :
run a monitoring script every 10 minutes from the server start/reboot time.
I was able to make it work at 10min after a reboot/start with :
#reboot sleep 600 && bash ./monitoring.sh | wall
however I did not have the repetition after.
the other way I was able to do it was :
* * * * * sleep 600 && bash ./monitoring.sh | wall
but this would wait ten minutes and broadcast each minutes after.
if I change to :
*/10 * * * * sleep 600 && bash ./monitoring.sh | wall
it does wait 10 minutes after start/reboot, but then broadcast at each 40, 50 minutes.
Can it be done with cron or do I need to go the script way ?
thanks.
How do you write a cron job which immediately run, then run on every hour divisible by 4? Say I started the script at 13:25, the job fires up right away, then the next run would be at 16:00, 20:00, 00:00 and so on.
For the first immediate run, just execute the command manually. Then set your cron up like this to have it execute continuously every 4th hour
0 */4 * * * yourCommand
This will run yourCommand every 4 hours (00:00, 04:00, 08:00......)
I have a script that I would like to run 60 seconds after initial system reboot and then every 10 minutes after that. I currently need two cron job listings to achieve this:
*/10 * * * * php myscript.php
#reboot /bin/sleep 60; php myscript.php
The first listing will run my cron job immediately after system boot and so I need to have the second listing to account for the on start wait time.
Is there anyway to combine the above two cron listings into one?
I am running a cron job which will run at every 5 minutes.
Now Let's say i have started job on 04:02 so it will execute at every 5 minutes so will execute on 04:07, 04:12, 04:17 etc...
Let's say i have started job on 13:18 so it will executed at 13:23, 13:28, 13:33 etc...
But what i want is it should only execute in multiplication of 5 minutes means if i create job on 04:02, it should start executing from 04:05, 04:10 and so on.
And if start job on 13:18, it should start executing from 13:20, 13:25 and so on.
So how to achieve this?
Try this:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * <Your command>
*/5 * * * *
this should be what you want .