If I have a cron job that runs every minute, and the first iterations runs for 62 seconds, will the second iteration wait to start until the first occurance ends, or can it happen that the same cron job runs concurrently?
To illustrate this, see scenario 1:
|0 |60 |120 |180 |240 |300
------ Cron Job 1 Taking 60 Seconds
--------- Cron Job 2 Taking 90 Seconds
------ Cron Job 3 Taking 90 Seconds but overlapping with the previous cron job
Is the above what will happen, or will scenario 2 happen:
|0 |60 |120 |180 |240 |300
------ Cron Job 1 Taking 60 Seconds
--------- Cron Job 2 Taking 90 Seconds
XXX-------Cron Job 3 waiting til the next 1 minute interval starts
My concern is that there will be a period for 30 seconds marked XXX where there will be NO cron job running.
What am I trying to accomplish? I want to execute a PHP script every single second, indefinitely. It doesn't have to run once a second, but it must RUN, END, RUN, END, RUN, END. If an iteration takes 5 seconds, it must only start the next one after the first has ended. But it must never ever stop. The problem is that I can't determine the length of an iteration. One iteration could take 1 second, or it could take 5 seconds, or even longer.
- Can cron do this? So that I can be guarenteed that the script will run every single second no matter what?
- If not, how can I gaurentee that a PHP script runs indefinitely, one iteration after the other?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…