PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 10th, 2012, 03:35 PM
sigurboy sigurboy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 6 sigurboy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 49 sec
Reputation Power: 0
PHP-General - PHP cron jobs

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?

Would the latter not execute until the first is done? Would they interfere with each other and cause conflicts?

Thanks

Reply With Quote
  #2  
Old November 10th, 2012, 03:51 PM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,879 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 2 Days 2 h 23 m 55 sec
Reputation Power: 581
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - PHP cron jobs

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap