Reputation: 407
I would like to run several scripts every half-hour. This obviously would work with this line
*/30 * * * * script.sh
My question now is how I would be able to run several of these at different times. As in, script.sh to run 5 minutes before script2.sh which then is 5 minutes before script3.sh. If that shouldn't be possible, any way to ensure that they aren't executed within 5 minutes of each other would suffice.
I did see solutions to do this with a script or otherwise programmatic. If cron can't be used for the job a "not possible" is what I'm looking for as the answer.
Upvotes: 0
Views: 48
Reputation: 1089
*/30
is equivalent to 0,30
. If you use the latter syntax you can simply use 5,35
for another job to offset it from the first.
For example, for three jobs you could do:
0,30 * * * * script1.sh
5,35 * * * * script2.sh
10,40 * * * * script3.sh
Note that if script1.sh
takes longer than 5 minutes to run, there will still be overlap between script1.sh
and script2.sh
. If you really must avoid that, you should probably consider lock files (using e.g. flock
).
Upvotes: 0