affordit Posted March 10, 2011 Share Posted March 10, 2011 When you use the sleep function in a script, will the script resume from that exact spot? I guess what I need to know is will it break an upload to MySql database of a csv file or will the whole file be uploaded? Thank All Quote Link to comment https://forums.phpfreaks.com/topic/230280-quick-question-about-sleep-function/ Share on other sites More sharing options...
btherl Posted March 10, 2011 Share Posted March 10, 2011 It'll resume from that exact spot. But keep in mind that external resources like the connection to your database or connection to the web browser may time out if you sleep for too long. Apart from that you should have no problems. Quote Link to comment https://forums.phpfreaks.com/topic/230280-quick-question-about-sleep-function/#findComment-1185883 Share on other sites More sharing options...
affordit Posted March 10, 2011 Author Share Posted March 10, 2011 I want to try this in a cron setting will that have any adverse effects? Quote Link to comment https://forums.phpfreaks.com/topic/230280-quick-question-about-sleep-function/#findComment-1185887 Share on other sites More sharing options...
btherl Posted March 10, 2011 Share Posted March 10, 2011 It depends on what you are doing. Quote Link to comment https://forums.phpfreaks.com/topic/230280-quick-question-about-sleep-function/#findComment-1185892 Share on other sites More sharing options...
affordit Posted March 10, 2011 Author Share Posted March 10, 2011 I have written a script that reads a directory of .gz files unzips to a new directory, them deletes the .gz files, and uploads the file to the database, and deletes the text file and it needs to go through about 300+ files. But some of the files have 750,000 + records and 30 seconds is not enough time so I need to break the upload down in the middle some where, and again before it starts the next file. I think I got that all right. Quote Link to comment https://forums.phpfreaks.com/topic/230280-quick-question-about-sleep-function/#findComment-1185901 Share on other sites More sharing options...
samshel Posted March 11, 2011 Share Posted March 11, 2011 If you sleep in between your script it doesnt reset the 30 seconds counter, if thats what you are trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/230280-quick-question-about-sleep-function/#findComment-1185909 Share on other sites More sharing options...
affordit Posted March 11, 2011 Author Share Posted March 11, 2011 That is what I needed to know thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/230280-quick-question-about-sleep-function/#findComment-1185911 Share on other sites More sharing options...
samshel Posted March 11, 2011 Share Posted March 11, 2011 You can increase the 30 second counter by using set_time_limit [http://php.net/manual/en/function.set-time-limit.php] though, in case it works for you. Quote Link to comment https://forums.phpfreaks.com/topic/230280-quick-question-about-sleep-function/#findComment-1185915 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.