Long Sleep() And Time-out's
The script I'm writing needs to wait a random amount of time (1-300s)
between each iteration of a loop, eg.
while(condition) {
do something
//wait between 1s and 5 minutes
sleep(rand(1,300));
}
Problem is, a browser times out if it doesn't get an answer within
about 30 seconds. Is the idea of having a PHP script sleep for a
longer amount of time incompatible with web applications? Any
work-around?
View Complete Forum Thread with Replies
Related Forum Messages:
Prevent Time-outs
My script needs to execute a time consuming process which might take as long as an hour or so to finish. Usually, the time limit would produce a time out after 30 seconds or so. Modifying the set_time_limit() does not resolve the problem since the browser then shows a could not display page error after 2 minutes or so. Also, I do not need to wait for browser output after the process finishes. Instead the server would send me an email. How can I get a script to work during an hours so without producing a time-out and being able to close the browser upon starting the script. Sort of "Fire and Forget".
View Replies !
Understanding Time Outs
I'm using apache+php I'm trying to understand how various timeouts work and where are the settings. web browser requests page index.php which does some long processing. When would the web browser time out. When would apache time out. Where are the settings. When would php time out. Where are the settings.
View Replies !
How Long Time The Query Take
I have a big query and I need to test how long time the query take. I want to test how long time the page need to load the data from database. Please let me how to get the page load time with PHP.
View Replies !
JPGRAPH Images On IE Take A Long Time
My images take forever to display in IE. If I click the stop button the images immedidately show up on the page. Can someone give me some hints as to what I can check for or modify to get this done faster? Status message line has "Downloading picture ..." Using win2k, IIS , PHP4.2 and lastest version on IE.
View Replies !
Long Time To Finish A Program
I have a perl program called by my php script, which in turn is called by the browser. Now, the perl program is called using exec, but takes a long time to finish. So, till the time the perl script does not finish its job, the browser does not show anything. I have messages like "Dont close this window", but that does not show up till the whole perl program finishes. Is there a way, I can somehow remedy this, try to show a message on the browser - "Please while your data processes" and then do the processing in the background?
View Replies !
Script Execution Time Too Long
I have a script that does a huge database update, which takes a long time. However, the host I am running on (and I suspect most hosts) are running in "safe mode." This means I cannot change the maximum execution time of scripts. So, the script stops right in the middle of doing the update. On top of that, I am trying to make code that I can distribute to others. As of now, the only way that this script can be run is with sys admin intervention. I would like to make it run without any help from the system administrator.
View Replies !
Too Long Time For Performing Script
There is a PHP – script on the server, which is worked out for a long time (over 10 min). The connection breaks up while performing the script and the absence of output to the client’s browser since the browser thinks that the server stops answering. How can I solve the problem that part of the PHP script on the server can not be performed because of connection interruption?
View Replies !
Status Note For Scripts That Run A Long Time
I got some script, that depending on the parameters it gets can take 20min or so to finish execution. When running the script for these 20min one sees nothing but a white page, which is somewhat bad, as the user think's something is wrong. So I wonder if there's a way to tell the user, that the script is still running and he's got to wait.
View Replies !
Long Time Responses Echo My Content
I have a php script than sometimes in a day takes long time to echo my content $starttime = echo $content $endtime = $total = $endtime - $starttime Is $total is greater than 30 seconds then i receive an email, my client is blocking my content because delays, Do you have any idea what could be the problem ? My script does at most 3 queries, then use a template to build my response, i get the content in a variable and then echo.
View Replies !
Dynamic File Download With *long* Response Time
I've got a Java servlet that delivers large database resultsets transformed to Excel with the HSSF library. In some cases it takes more than 15 minutes before transformation is done and content can be delivered to the browser. I want to show the "Save As" dialog as early as possible so the user knows he's not lost and forgotten. I already tried to send the response headers immediately after receiving the request including content disposition and filename. Even though the browser receives those headers it just won't trigger the "Save As" dialog. This applies to both MS IE and Mozilla...
View Replies !
Apache And Fopen Taking Long Time To Open
I now have a file called a.php in my Linux server website root directory - nothing else in it but: <?php echo time() ; $fp = @fopen("http://www.a-website-feed.com/feed.xml","r"); echo time() ; ?> when I access www.mysite.com/a.php from IE - it takes about 25 seconds to complete. On the server, when I go to the directory and run: php a.php it takes 2 seconds? I guess its an apache/php problem. Has been working for ages now but suddenly causing problems.
View Replies !
How Long Is Too Long For A Script To Execute? GetTimer()
I'm using some scripts and they're executing from .007 - .010 It defines many files, imports several files (total of maybe 20), encrypts 2 strings several times base64 IN flash, WWW-Authenticating to a PHP file, PHP grabs a MySQL Query, returns it, traces it. That happens all in .007 seconds roughly. How long is too long until you should find a new script. If a script runs with a time of .05, is that the general limit or is that fast?
View Replies !
Strtotime And Dates Long Long Ago ...
while making an encyclopdie on my hometown (dutch, http://www.kgv.nl/index.php?id=610) i am trying to use dates prior to 1970. birthdates in, let's say, 1615. i'm getting errors while working with these dates, for example when i am calculating which day of the week it is. the dates are stored in a mysql database. is there another way to convert stringtype dates to work with?
View Replies !
How Long Is Too Long For A Cgi Script?
I have a 4000 line php cgi script that is not memory or cpu intensive. It runs in 1 second. Now I am getting a lot of customer requests to add in new features. My question is if there is a point where my code will be too long and take too long to run (i.e > 5 seconds). I would really like to have my script rival the functionality of a desktop application but can php do it? My server is a dual processor with 2GB ram.
View Replies !
PHP Sleep()
I've been sitting for quite a while now, reading the sleep() manual and tried to turn the code upside down and inside out but nothing helps... I want the current page to wait a few seconds before it is directed to another ( after a successfull registration ). So i thought the best way to do that is to use sleep(). However, this does work to a certain point ... the current page waits for 5 seconds, but the text I want to show the user in the meantime doesn't show? Why? Without the sleep() and the header() it shows without any problem. Code:
View Replies !
Sleep()
I tried to make a script which would print a line of text at 1 line per second or whatever time i put. So i went ahead and tried this. PHP Code: echo "Passwords match."; sleep(1); echo "Passwords match."; sleep(1); echo "Passwords match."; sleep(1); echo "Passwords match."; This is a example and the text in echo has no meaning. However the sleep waits and waits for all the other sleeps to finish and then prints out all text at once.
View Replies !
PHP Messaging And Sleep
I would like to get my php script to send a message to a user for example to notify that a DB update or insert has been successful or not. After that the script will be redirected to the home page. how can this be done ? I have tried using sleep(5) to delay the script but that does not work the way that I want it to since it simply delays the execution of the ENTIRE script RATHER than a part of it !!
View Replies !
Sleep() In The Background
how much the sleep() which is set to no limit can consume the system resource. Could it cause to hang the server? I tried the following and couldnot see the server got busy. Although the browser seemed to be so, if I access to a different page, it responded very quick as usual. It's not a big deal, is it? sleep.php PHP Code: <?php set_time_limit(0); sleep(0); ?> fork_sleep.php PHP Code: <?php $str = "php -f sleep.php"; exec("$str > /dev/null &"); ?>
View Replies !
Fsocketopen & Sleep
I'm trying to setup a fsocketopen script to ping a site every 15 minutes or so and if the site is down, send an email. I'm thinking of using ignore_user_abort() to run the script in the background and sleep() for the time intervals. I'm not really sure how to script this out.
View Replies !
Sleep And Max_Execution_Time
I have the following code: $i=0; while($i++<15) { mail("rantsh@hotmail.com",date("d m Y H:i:s"),"This is email # $i "); echo "mandado $i <br>"; sleep(60); } Now, I know my server has a 30 second max_execution_time setting... nonetheless, this code runs successfully!!!. Now, this is actually better for me (for the application I need to run)... Yet I'm concerned of why it's being allowed to run for 15 minutes if max_execution_time is set to 30. Code:
View Replies !
Would I Use Sleep To Delay
I am making a site for a friend, but with his PHP it always renders too quick and I would like it to wait a bit for the rest of the page to load, otherwise its a bunch of annoying gaps and whacked alignment as the CSS and images load and it all just looks annoying as it loads. And it takes away from the order of of information outputted as it goes through the PHP when your focused on the tripped out layout.
View Replies !
Sleep Function
I'm playing about with delaying results of a PHP program. I want to print some results then wait for a few seconds and print some more. I have found the php sleep function however have a small problem. <?php echo ("The time in 3 seconds from page loading: "); sleep(3); echo date('h:i:s') . " "; ?> The above script is meant to print the top line, wait 3 seconds and print the bottom line. Infact, it starts, waits 3 seconds and prints all at once. Now from my understand from php.net it should not sleep untill it hits the sleep command in there.
View Replies !
Sleep For 10 Seconds Help
I am trying to run it will load an iframe for every entry found in my DB, I am trying to make it sleep for 10 seconds between each iframe with: PHP Code: sleep(10); PHP Code: $train = "<table width=800 bgcolor=F0F0F0 aling=center><tr><td colspan=4> $pages<br></td></tr>"; $i=0; while ($addall = mysql_fetch_assoc($res)) { Â Â Â Â if ($i/2 == ceil($i/2)) $train .= "<tr>"; Â Â Â Â $i++; $train .= "<td width=120 valign=top><BR><iframe src="potspace.php?u=$addall[intId]" width="400"></iframe>"; } $train .= "<tr><td colspan=4><br><br> $pages<br><br></td></tr></table>";
View Replies !
Login Script That Checks Long Long It Has Been Since A Last Login
i need to make a login script that checks long long it has been since a last login. I have Mysql so i can use that to store the last login date. Can someone help me figure out how to find how many days ahve passed since a previous login. Like what format should the last loin date be stored in. Also how i get it to figure out how many days have passed since the last login.
View Replies !
Session Timeout, Use Of Sleep Ect...
I have a custom script that uses sessions to track UID's. The only problem I have with the script is that the session times out in 1440 (min?) which I believe is 24 min. I was thinking that I could use php's sleep to hold off from doing a refresh until minute 20. Unfortunately, I have also read that using sleep can leave a server open to a DoS attack. I do not have access to the php.ini file to be able to change the timeout variable for the session. What is the best way to keep a session open without changing the .ini variable. Is sleep a good way do go about it, and if so, are there significant security risks in using sleep()?
View Replies !
Sleep() Affects The Variables?
could it be that the sleep() function affects my variables? When I set a very long delay time (1-3 hours) in my CronJob PHP4 script (of couse with a big set_time_limit) some of my variables go lost! But there's no problem with short times in the sleep-function (1-5 min). set_time_limit(86400); for($x=1;$x<5;$x++) { echo $x; //$x will be shown only one time sleep(7200);}
View Replies !
Need To Flush Before Sleep But I'm Blank.
I'm new to php and am converting a bunch of asp pages to php. Current problem : I am using a Submit button on a form to POST ( send the database variables ) to a php page that will send a personalised e-mail to each client. On the php page, I am looping through a database, compiling a message ( html format ), and mailing the message to my client. After the mail has been sent, I need to wait for 4 seconds before continuing with the next database record. I am using this code after the mail has been sent : echo "Mail Sent to : " . $row['CliName']; ob_flush(); flush(); sleep(4); Problem is, that nothing appears after I click on the Submit button on the first page's form ( the first page just remains on the screen ). Once the database has been looped, the entire (correct) output appears on my screen - but I need to see some sort of progress as it works it's way through the database.
View Replies !
Sleep(900) ? Delayed Query... ?
Trying to set a marker in a MySQL table on our Primary host (WAMP stack) indicating whether or not there is current User Activity -- ON THAT SERVER -- as a signal to remote Secondary -- tablet pc based servers to skip scheduled database synchronization with the Primary. Code:
View Replies !
Sleep() And Browser Load.
is there a way to get around the browser continually acting like they are loading when using sleep()? It says the page is still loading but it really isn't because we are causing a delay for some data on purpose with php. So it is for an intentional reason that we cause it. Many of us like using sleep(). Anyway to do it without the browsers showing the page is still loading? There must be a way, so many programmers for intense programming use sleep(), I can't imagine they have to deal with the browsers loading prompts whenever they do.
View Replies !
Staggering Execution With Sleep()
For my site, currently in development, I will be hosting some latest RSS picks from friend websites. To start with there will only be a couple, but eventually I hope to be sourcing from up to 50 partner blogs. Obviously, i dont want to make a request on every page load, so I would instead cache data from the past half hour/hour. I will be using CRON to schedule an update every so often, but having a single script making 50 requests one after the other then processing and storing the data may be taxing, especially if the outside server is slow. I thought about using sleep() to leave gaps between each request so that a sudden hogging of resources doesnt happen every hour. What are your views on this method? Is it feasable (and possibly even a good idea), or should I just get it all to execute in one go?
View Replies !
Resources Used When Using The Sleep() Function
I want to use the Sleep() function in a script that may run multiple times, but i dont want hte system to crash or be overloaded with scripts in memory. When the script enters a sleep mode, what happens to the script? is it resident in memory? if so could i experience the system bogging down if there were 100+ scripts resident in memory or are they just sitting there doing nothing until they run again?
View Replies !
SLEEP + Header Problem
I'm running a community website where I send out weekly newsletters to all of my clients. However, I'm sure my hosting provider wouldn't be so happy if I just FOR LOOP and send it all out at once. SO what I did was I just a SLEEP and a header mthod that triggers after every second, where the header sends out GET variables for the next iteration to fetch at which account I am currently at to send the next newsletter. Code:
View Replies !
Insert Sleep Every X Rows
i am trying to insert a sleep command in my loop every 100 rows, the below works for every 2 but if i try to sleep every 100 rows it will not work. if($i % 2) { sleep(5); } does not work [php] if($i % 100) { sleep(5); } [/php
View Replies !
Putty Processlist Command Sleep
I'm using php with mysql. I am connecting through putty and I run the command for processlist. Lately I am seeing many threads with the command "sleep" in them. My site and the database are running smoothly, but I am seeing up to 200-300 threads like this with the command "sleep". Can anyone tell me what may be causing this and how do I resolve it? Or is it normal to see this when your site grows to a certain size? Code: ......
View Replies !
Require_once And Fatal Errors... Automatic Sleep And Try Again Anyone?
I have a PHP page which loads OK 80% of the time. However the rest of the time I get the following error: Fatal error: Failed opening required 'DB.php' This really bugs me, especially since the only reason this is happeneing seems to be due to server load. I would like to add code so that instead of displaying the given error, the PHP code makes the HTTP response thread simply sleep a little bit (say 4 seconds), and then retry, and repeat until the file can be opened. It seems strange to me that server load would prevent the file from being opened. Anyhow, any ideas on how I can improve the situation?
View Replies !
Max Execution Time Means Server Execution Time Or Client Browser Hung Up Time?
The max execution time is set up to be 30. When I submit the requests of execution through the client browser, it shows the execution was running. It still hung up there after 30 seconds, after 2 minutes ... And the browser hung there forever. I have another page which saves the reports of the execution, so I open another browser window, and check out the report. It shows me the execution is still going even after 1 minute, 2 minutes... Code:
View Replies !
SHOW PROCESSLIST "sleep"
when i view SHOW PROCESSLIST i always see command sleeps with some large times behind them.. can somone please tell me what that is and what that might be caused by? "Command" Sleep "time" 1585
View Replies !
How Long For A Session?
how long a session lasts for. It's been a long time but I thought it was 20 minutes by default. IS this correct or is it some other time? Assuming the browser is not closed of course.
View Replies !
Long Text
im trying to figure out how to format text in a database ... If I have a TEXT AREA in a form .. and an user inputs say like 5 paragraphs ... how can I have it to where mysql will display that as 5 paragraphs and not just i chunk of text when i display it at a later date ?
View Replies !
Long Insert
I need to update a table in mysql and the information is very long. I changed it to Longtext and whenever i use php to update it, the query returns true but the data never gets inserted into the database. Here is an example of the text that would be entered: Code:
View Replies !
Long String
I have made a forum, it is working fine. Came accross a new problem today, someone posted a long website address, and the table that the text is written in stretched to fit it, making the page much wider than it should be. How can I make sure that long web addresses or wordswithoutspaces will not ruin the aesthetics of the forum?
View Replies !
One Long Line?
I was wondering, when I view my source in the browser my PHP code shows as one long line. Any ideas why this is?
View Replies !
Long Decimal
I am using PHP 4.3.3 I am developing a site about astronomy the needs high precision calculation (that will use numbers of 20 decimal points). I've increased the precision value in php.ini to 25, but PHP seems to accept only 15 decimal points.
View Replies !
Oracle + PHP + Long Process
Oracle 10g RAC on Linux, with an end-user interface via Apache/PHP/AdoDB on a separate Linux box. I need to create a PHP web interface to allow an end-user to run a PL/SQL stored proc that will do a force refresh of a series of materialized views following the loading (through another PHP interface) of additional flat file data into the underlying tables. I want to allow multiple data uploads and then do a single refresh, so I won't be able to use fast refresh or other internal database trigger mechanisms. My real problem is that the time taken to execute the stored proc is likely to considerably exceed the max script execution time for PHP, and I don't want the end-user interface to just sit there bubbling away waiting for the Oracle processes to return a response anyway. I am considering creating a "master" PL/SQL stored procedure which would use the Oracle DBMS_SCHEDULER package to run a nearly-immediate job as a "background" (to the PHP interface) process. Is this the way to go, or are there other better solutions that I am overlooking?
View Replies !
How Long Can I Make A Cookie Last?
I realize that the "cookie" is not a PHP-specific topic. However, I'm developing my web site using primarily the PHP programming language so I thought that the PHP forum would be an appropriate place to post this question. My question is this: Is there a limit on the amount of time that a cookie will remain on a user's computer? In other words, if I code a time frame of a year or two for the cookie to expire will the cookie stay on the user's computer for that long?
View Replies !
|