0

I run several cron jobs every minute - I use flock to prevent overlapping as a couple of the scripts may run for over minute:

* * * * * flock -n /path/to/lock-process-1.txt php /path/to/process-1.php

* * * * * flock -n /path/to/lock-process-2.txt php /path/to/process-2.php

However, all the processes run at the same time (and most of the processes only take a few seconds). So I'd like to stagger the crons so that they are ten seconds apart. I have read elsewhere that this can be done with sleep (from this post):

* * * * * sleep 10;curl http://www.google.com/

My question is: can I use sleep alongside flock and if so, where do I add the sleep 10;

Ryan
  • 152
  • 1
  • 13

1 Answers1

0

I went ahead and tested this and it is OK to have sleep before flock:

* * * * * sleep 10; flock -n /path/to/lock-process-2.txt php /path/to/process-2.php
Ryan
  • 152
  • 1
  • 13