darcyf1.com Posted August 11, 2009 Share Posted August 11, 2009 I have searched everywhere and asked quite a few people and got no where. I have a script running that gets a certain set of files (info retrieved from mysql database) and then executes a shell command that zips them all into a zip file for easy download. THE PROBLEM! Sometimes the collection of files (videos in this case) can be quite large. Running the shell command to zip such large files can take up to 10mins for 2GB and runs successfully. [i am not looking at collections quite that big for my script] When I try to call this command during the php, it runs for a little more than 30 seconds, and if it hasn't finished by then, it fails and I am returned an 'Internal Error Page'. If the command does finish, then the script works perfectly well. I have tried things like playing around with; set_time_limit, max_execution_time, max_input_time etc. I do not have direct access to php.ini (as I am hosting with a company). Any suggestions would be greatly appreciated!! <?php set_time_limit(0); $files = ""; $count = 0; $nameofzip = "$race"; $nameofzip .= "$season"; $nameofzip .= ".darcyf1.zip"; $con = mysql_connect("$address","$user","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$table_name", $con); $sql = "SELECT * FROM clips WHERE (Cat='$series') AND (Season='$season') AND (Race='$race') AND Full IS NULL"; $result = mysql_query($sql); if($row = mysql_fetch_array($result)){ do { $files .= "{$row["Link"]} "; $count = $count + 1; } while ($row = mysql_fetch_array($result)); } mysql_free_result($result); shell_exec("zip $nameofzip $files;"); echo "<br /><strong>$count files zipped - <a href='../go.php?c=$series&f=$nameofzip'>Download</a></strong>"; } ?> I repeat, the code works perfectly if the command doesn't take too long! Thanks, Darcy! Link to comment https://forums.phpfreaks.com/topic/169737-time-out-stopping-my-php-shell-script/ Share on other sites More sharing options...
darcyf1.com Posted August 11, 2009 Author Share Posted August 11, 2009 Hoping this doesn't disappear of the first page I would be really grateful if someone can solve this problem that I have spent way too long thinking about! Link to comment https://forums.phpfreaks.com/topic/169737-time-out-stopping-my-php-shell-script/#findComment-895552 Share on other sites More sharing options...
Mark Baker Posted August 11, 2009 Share Posted August 11, 2009 Your web server probably also has a timeout value, but if scripts really do take a long time to execute, you should probably consider running them from the command line or via a cron task Link to comment https://forums.phpfreaks.com/topic/169737-time-out-stopping-my-php-shell-script/#findComment-895572 Share on other sites More sharing options...
darcyf1.com Posted August 11, 2009 Author Share Posted August 11, 2009 Your web server probably also has a timeout value, but if scripts really do take a long time to execute, you should probably consider running them from the command line or via a cron task But how would I go about doing that? I can run the command manually, but I can't sit there all day waiting for requests to come in, and then I assemble the zip file manually. I'm all out of ideas :S Link to comment https://forums.phpfreaks.com/topic/169737-time-out-stopping-my-php-shell-script/#findComment-895575 Share on other sites More sharing options...
darcyf1.com Posted August 12, 2009 Author Share Posted August 12, 2009 I spent another couple of hours looking around for a solution to this, but none of the suggested 'solutions' have any affect, really frustrating! Link to comment https://forums.phpfreaks.com/topic/169737-time-out-stopping-my-php-shell-script/#findComment-896216 Share on other sites More sharing options...
felicityinneed Posted August 24, 2009 Share Posted August 24, 2009 I have the same problem. The cron jobs are heavy and take a long time to execute sometimes, and I have used set_time_limit to 300 while the cron jobs are set to 5 minutes interval. Sometimes when the crons take too long to execute the cron jobs stop completely without sending any mails or the subsequent crons executing. I am in a lot of pain because of this, added with the 500 internal server error pages that come up when these crons stop executing sometimes. Please help somebody. Link to comment https://forums.phpfreaks.com/topic/169737-time-out-stopping-my-php-shell-script/#findComment-905343 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.