
November 10th, 2012, 03:51 PM
|
|
|
Quote: | Originally Posted by sigurboy Hello,
If I have a PHP script that takes 2 minutes to run, I was wondering what would happen if it is setup by the cron to run every minute?
|
It would run every minute.
Quote: | Originally Posted by sigurboy
Would the latter not execute until the first is done?
|
It will run whenever cron starts it. Cron does not care (nor does *NIX) if there is another copy of the script already running.
Quote: | Originally Posted by sigurboy
Would they interfere with each other and cause conflicts?
Thanks |
They can but it depends on what resources they use. This is really a *NIX question not PHP. For example if they are both trying to write to the same file, that will cause problems. If they are trying to read a file that the other is updating then the data being read may not be valid.
That having been said, if you know the script runs for more than a minute then why would you set cron to run that often? What most admins do in this case is to start the script on boot, then just before it exits, have it issue an 'at' command to kick off another run in 2 minutes. That way it will always run 2 minutes after the last execution regardless of how long it takes to complete.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.
|