monkeypaw201 Posted February 26, 2008 Share Posted February 26, 2008 I need to basically run a PHP Cron, i need it to limit it to 500 records at a time, fine and dandy i know how to do that.. now how can i have on a different Cron/Page, the script start from 501 and go for another 500 :o Thanks Quote Link to comment https://forums.phpfreaks.com/topic/93044-php-challenge-break-and-resume/ Share on other sites More sharing options...
rhodesa Posted February 26, 2008 Share Posted February 26, 2008 Out of curiosity, why are you limiting it to 500? Quote Link to comment https://forums.phpfreaks.com/topic/93044-php-challenge-break-and-resume/#findComment-476683 Share on other sites More sharing options...
monkeypaw201 Posted February 26, 2008 Author Share Posted February 26, 2008 Out of curiosity, why are you limiting it to 500? Because the scripts are large, and i dont want to overload the server Quote Link to comment https://forums.phpfreaks.com/topic/93044-php-challenge-break-and-resume/#findComment-476684 Share on other sites More sharing options...
rhodesa Posted February 26, 2008 Share Posted February 26, 2008 if you want to pace the script, use something like sleep() or usleep() http://us2.php.net/manual/en/function.sleep.php <?php $n = 0; while(...){ //do some stuff $n++; if(!($n % 100)) sleep(10); //Take a 10 second break every 100 records } ?> or <?php while(...){ //do some stuff usleep(100); //Take a short break } ?> Quote Link to comment https://forums.phpfreaks.com/topic/93044-php-challenge-break-and-resume/#findComment-476689 Share on other sites More sharing options...
DarkerAngel Posted February 26, 2008 Share Posted February 26, 2008 if you want to pace the script, use something like sleep() or usleep() http://us2.php.net/manual/en/function.sleep.php <?php $n = 0; while(...){ //do some stuff $n++; if(!($n % 100)) sleep(10); //Take a 10 second break every 100 records } ?> or <?php while(...){ //do some stuff usleep(100); //Take a short break } ?> Couldn't this possibly trigger max_execution_time Thought about it his script might do that anyways. Quote Link to comment https://forums.phpfreaks.com/topic/93044-php-challenge-break-and-resume/#findComment-476695 Share on other sites More sharing options...
monkeypaw201 Posted February 26, 2008 Author Share Posted February 26, 2008 Couldn't this possibly trigger max_execution_time Thought about it his script might do that anyways. Right, this is to supposed to avoid server overload and the max_execution_time Quote Link to comment https://forums.phpfreaks.com/topic/93044-php-challenge-break-and-resume/#findComment-476696 Share on other sites More sharing options...
rhodesa Posted February 26, 2008 Share Posted February 26, 2008 You said this was going to be a cronjob, which is using PHP via the command line interface. When run from CLI max_execution_time is set to unlimited. As for 'server overload', the script will take up an unnoticeable amount of resources while it's sleeping. Edit: To clarify, the amount of time it takes a script to complete is not related to the amount of load on the server. Quote Link to comment https://forums.phpfreaks.com/topic/93044-php-challenge-break-and-resume/#findComment-476702 Share on other sites More sharing options...
trq Posted February 26, 2008 Share Posted February 26, 2008 Just to add to rhodesa's comments, depending on what exactly your scripts do you may not even need php at all. What do you want these cronjobs to do? Quote Link to comment https://forums.phpfreaks.com/topic/93044-php-challenge-break-and-resume/#findComment-476709 Share on other sites More sharing options...
monkeypaw201 Posted February 26, 2008 Author Share Posted February 26, 2008 they need to update some databases with new information gotten from external websites Quote Link to comment https://forums.phpfreaks.com/topic/93044-php-challenge-break-and-resume/#findComment-476953 Share on other sites More sharing options...
synstealth Posted February 26, 2008 Share Posted February 26, 2008 try looking into AJAX.. Quote Link to comment https://forums.phpfreaks.com/topic/93044-php-challenge-break-and-resume/#findComment-477008 Share on other sites More sharing options...
rhodesa Posted February 26, 2008 Share Posted February 26, 2008 try looking into AJAX.. While AJAX is great, it has nothing to do with the current topic. Quote Link to comment https://forums.phpfreaks.com/topic/93044-php-challenge-break-and-resume/#findComment-477026 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.