Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





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 Complete Forum Thread with Replies

Related Forum Messages:
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 !
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>&nbsp;&nbsp;&nbsp;$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>&nbsp;&nbsp;&nbsp;$pages<br><br></td></tr></table>";

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 Function Or Any Thing Like?
i wanna make search page when you submit the search form it will direct you to search page but before the search starts i wanna make it waiting how can i make this.

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(), Exec() And MySQL
How to create dynamically generated table .....

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 !
Processlist Sleep Command
a couple times i have notice the command sleep, with times like 200 or even 1700, what might be the cause of this? anyone know?


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 !
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 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 !
Cgi Execution Through PHP
I have a very old C++ program which is located in /cgi-bin/ directory.The problem is that the program is designed to work on the cgi-bin dir and I want to take the output of that program in order to create a simple HTML page with the help of PHP. I tried the system(), but system wants absolute path and seems that it cannot run a program as a cgi. So, I tried virtual.

View Replies !
Execution
I have an signup script that creates accounts automatically on a server - I also have one that deletes a reseller account and all of its accounts within it. After the user has started the script (the delete one), if they stop the execution half way through then not all of the accounts get deleted.

I don't want to have to have a cron oging because it needs to be instant however I still need a way so that a php script is executed and then the user can do what they wish - it wont make a difference.


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 To Prevent Tag-execution
perhaps this question is too easy, so i cant find an answer, or i'm too stupid. However, i'm writing a guestbook, and i don't want the tags user could write to be executed. This must have an easy solution, cause its used in evry forum or guestbook, isn't it? Can the tags be escaped? but do i have to replace every single existing tag, or is there a specific function?

View Replies !
Self Execution Of Php Scripts?
Is it possible to set a php script to execute itself, say at a given day each week?

I have created a script that automatically generates a newsletter based upon new items i have added to my product database, however I have to access the page each week in order to send the newsletter.

Is there any way to automate this process?

View Replies !
Command Execution
how do i run "perl /cgi-bin/cool.cgi" from within php file (4.1.0) on win 2000 with IIS.

i know the paths to perl.exe and absolute path to cgi file also. i tried system("perl ......"); and exec(".......") but didn't work.

View Replies !
Parallel Execution
I would like to start from a PHP program another PHP program in such a
way that the calling program can continue it's execution (after
started the second program, both must be executed in parallel way).

It's is possible to do this? There is someone that can suggest me how
I can reach my objective?

View Replies !
Automatic PHP Execution?
I have the following question,
I have an application which transfers a csv file (via FTP) to the server
then on the server I have a PHP script which put the content of the CSV into
a mysql
The question is now how can I start without manual interaction this PHP file
?

View Replies !
Max Execution Time
I am having problem with max_execution_time, I am always getting error.
Fatal error: Maximum execution time of 150 seconds exceeded in C:wampwwwFINALincludesmodel.class.php on line 298 First I had kept 60 second, then increased to 120 and now 150, still shows this error.

Will this max execution time makes the page load slow ? Or is this a problem with PHP.

View Replies !
Program Execution
I am using php to write inputs I receive from browser into a text file.Than I use shell_exec() to execute a program on server that writes those inputs from the text file and write its output to another text file. Now after my program has written its output I want to read this text file from php and send it back to the browser.

View Replies !
File Execution
I have a problem in executing a php file. When i click on the corresponding link of the page, actually i am expecting a new result page consisting of records retrieved from mssql database. But my problem is rather than showing the resultant page containing mssql records, i am getting a 'Save As' dialogue box and stop execution of the script. What is wrong with?

I am using php5, mssql and apache2. But before on the php4 platform the same script execute without any problems.

View Replies !
PHP Execution Speed
I have a small app that I would like some advice on. I am pulling a rather large amount of data from a MySQL table and sometimes the execution can be as long as 15 to 18 minutes. I would like to know if anyone has any suggestions for a different approach that might lead to faster results. Code:

View Replies !
PHP Execution Time
I have a very complicated site with a lot of PHP and mySQL code which I've redesigned to reduce overhead. This site is recieves a lot of hits.

The total time to process a page is about 0.3 seconds on the current server. Is this excessive?

View Replies !
Search Execution
I am having a problem with the following script, it allows a user to search for suppliers in a given county. The problem is the search is not executing, I have tried printing the query and error reporting but it is not working at all, any ideas?

PHP Code: .....

View Replies !
Restricting PHP Execution
I am running Apache 1.3.33 and PHP 4.3.11. Is there a way, either via httpd.conf or php.ini, to restrict which directories can be used for the execution of PHP scripts similar to how you can restrict cgi scripts to be allowed to run only if they are in a cgi-bin directory.

View Replies !
Maximum Execution
I have a rather complex script that does some maintenance to a product database containing somewhere in the vicinity of 1,000 products. Unforunately when I try to execute the script it gives me "Maximum execution time of 30 seconds exceeded".

Is there a way to fix this so it still does all of its functions in one execution without timing out. Or, is there a way to tell PHP to have a longer timeout then 30 seconds to allow for this script?

View Replies !
Remote Execution Bug?
I would appreciate it you folks would answer a couple of basic
questions about the "Remote execution" error:

1. Is it a browser issue.
2. Is it a PHP version issue.
3. Is a a $HTTP_POST_VAR[] vs. $_POST[] issue?
4. Is a a $_POST vs. $_GET[] issue?

I'm trying to use ezContents CMS calendar module, which is called from
a menu link, the module path is
/ezcontents/modules/calendar/calendar.php.

5. Is there a programming change I can make to make this module run
more safely?

View Replies !
Stop Execution
I have this line bellow in my script,but the program don´t stop. Where i´am wrong? if you click in "Cancel" button,the data should be deleted like if you pressed "Ok" how can i resolv this?

print
"<script language=javascript>
if (window.confirm('$msg') == false ){
window.parent.location='set.page.php?$param'
document.execCommand('Stop');
}
</script>";
stop("ok");
die;
//Mount delete query according each table field types situation
$query="DELETE FROM $table WHERE $where";
$result=mysql_query($query) or die("Erro de exclusão! Contate seu webmaster (#27)");
parent_location("set.page.php?$param");

View Replies !
Execution In The Background
I want a php script to be executed in the background when the admin presses a button in an application which is running on a Linux environment. This page execution will take a long time(Maybe 16 hours).

There I want the window in which the administrator presses the button to display logs of the background executing script after this script has been started. How do you go about acheiving this?

View Replies !
Execution In Unix
How do I execute a php script in unix from the command line?

View Replies !
Quicker Execution
Delete queries take a long time to run and I'm looking for ways to speed them up without having to delete or move data.I usually delete rows where the date field is equal to a particular date. So my query looks like this: DELETE FROM my_table WHERE date=&#55614;&#57159;-04-20'
My tables generally have from 800,00 to 1,200,000 rows and it takes about 20 minutes for this query to run even though the date field is indexed. Does that sound slow? Is there anything else I can do to speed it up.



View Replies !
Sporadic Execution
why the following might work on some servers and not others? I am certain it has somthing to do with a setting in php.ini, just not sure what that setting is. One some servers, I see nothing at all.

<?php
set_time_limit(0);// to overcome maxexecution time
$sep = "ofaLlTherCrzyThInggsIhaveayeard";

$file = "./data.txt";
header("Content-Type: multipart/x-mixed-replace; boundary=$sep");
do {
print "Content-Type: text/plain

";
readfile($file);


View Replies !
() Execution Time
I was recently testing some PHP code and found that a single line using gethostbyname() to fill a single variable was taking up about 3.5 seconds to execute.

View Replies !
Need The Value That Was Found In Later Execution
this is the issue

function{

echo(" ____________");
$x=0

EXECUTION of FUNCTION

$x reaches a new value at the end of the function

}

In the echo statement, I would like to echo the final value of $x. Is this impossible?

View Replies !
Execution Of Php Script
I'm trying to create a php script that unlinks a specified file after a specified number of hours. for several hours directly from within a user session is unacceptable. Is there a similar downside if a separate script active in the user session used shellexecute to launch the sleep/delete script.

View Replies !
Do-while Loop Won't Run After First Execution
Below is the code for the section of the page im working on. I am creating a horizontal nav bar with drop down menus - much like this: DROP DOWNS EXAMPLE

All of the content in the nav I currently have in two tables a categories table and a subcategories table: Code:

View Replies !
.php File Execution
I just typed the following code in a notepad and saved it as "phpinfo.php"

<html>
<body>
<?
print("Hello");
?>
</body>
</html>

Thing is I don't know how to execute this file.

I installed "Apache5.0" in my system. Is there is anything more need to be installed?
I also have "php5.0".When i installed "php5.0",it says that it couldn't recognise the server(some files in the server were mising.......).

When i the saved the file with ".php" extension, it just looks like normal ".txt" file. Where the ".php" file should be saved(anywhere in the system or in the server)? Anyone please do tell me all the steps in executing the ".php" files.

View Replies !
Execution Problem With 4.4 Vs. 4.2.2
I have a page that used to work fine with PHP 4.2.2 but after upgrading to
PHP 4.4 it does not work so well.

In short, after starting ftp transfer of 80MB, a new page should pop up and
display something like "Transfer in progress, please wait ..."
As soon, as the transfer is done, the result (Success or Failure) is displayed.

With PHP 4.2.2, all is fine. With PHP 4.4 the new page is blank until the job is done.
Then it will display everything.

I tried different execution functions, but it does not make any difference.
It's Linux machine with Redhat 8.0 and Appache server.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved