csplrj Posted September 5, 2009 Share Posted September 5, 2009 I have a long running script which may go on for long time may be 4 to 5 hours? How to get running the same in a shared hosting environment? As I tried the same but it seems it does not works in a shared hosting environment? I tried set_time_limit(0); ignore_user_abort(); but it does not seems to works Thanks in advance CSJakharia Link to comment https://forums.phpfreaks.com/topic/173206-running-long-running-script-in-shared-hosting/ Share on other sites More sharing options...
Mark Baker Posted September 5, 2009 Share Posted September 5, 2009 Anything that takes longer than a few seconds (at most, a couple of minutes) to run should not be executed from a web page. Instead, you should run it as a cron job Link to comment https://forums.phpfreaks.com/topic/173206-running-long-running-script-in-shared-hosting/#findComment-913024 Share on other sites More sharing options...
bundyxc Posted September 5, 2009 Share Posted September 5, 2009 If your host doesn't support cron, try something like this: <?php session_start(); $timer = 5; $refresh = $_SERVER['REQUEST_TIME'] + $timer; while (1) { if (time() >= $refresh) { die('<meta http-equiv="refresh" content="0">'); } else { //Execute code } } ?> Here's an example of something that you could do: <?php session_start(); $timer = 5; $refresh = $_SERVER['REQUEST_TIME'] + $timer; if (!isset($_SESSION['i'])) { $_SESSION['i'] = 0; } while (1) { if (time() >= $refresh) { die('<meta http-equiv="refresh" content="0">' . $_SESSION['i']); } else { $_SESSION['i']++; } } ?> Code above counts, saves as a session variable, refreshes every five seconds, and starts where it left off. What exactly are you trying to do? Link to comment https://forums.phpfreaks.com/topic/173206-running-long-running-script-in-shared-hosting/#findComment-913039 Share on other sites More sharing options...
csplrj Posted September 5, 2009 Author Share Posted September 5, 2009 It parses the html content of a website and gets the data from the html which is required to me Link to comment https://forums.phpfreaks.com/topic/173206-running-long-running-script-in-shared-hosting/#findComment-913103 Share on other sites More sharing options...
bundyxc Posted September 5, 2009 Share Posted September 5, 2009 If you show me the code that you plan on using for the 4/5 hours, I'll implement it into my idea. Link to comment https://forums.phpfreaks.com/topic/173206-running-long-running-script-in-shared-hosting/#findComment-913278 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.