943,545 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 15994
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
May 9th, 2007
0

Run PHP script every 10 seconds

Expand Post »
Hello together...

hope someone can help me:-)

I want to to run a php file every ten seconds on serverside,
how can I do this?

CronJobs are not really working; Server = Apache, PHP 4 or 5.

Greetings & Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
maninweb is offline Offline
11 posts
since Jun 2005
May 9th, 2007
0

Re: Run PHP script every 10 seconds

Why do you need a script to run every 10 seconds? There has to be a more efficient way to do whatever it is you are trying to do.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
May 9th, 2007
0

Re: Run PHP script every 10 seconds

Cron jobs are your easiest solution.
Another method would be making 2 PHP scripts to bounce off of each other.

File 1: Run the target script wait 10 seconds and call File 2.

File 2: Run target scritpt wait 10 seconds call File 1.

It would be advisable to make a script take in a $_GET value to 'exit' the scripts.

So once you go to file 1: in your browser, it will create a continuous loop which will bounce form one file to the next. Until you type in this exit command.
Reputation Points: 35
Solved Threads: 5
Junior Poster
dr4g is offline Offline
136 posts
since Apr 2007
May 10th, 2007
0

Re: Run PHP script every 10 seconds

Hi...

thanks for your responses. Well, I need it because I must update
database entries and perform new calculations every ten seconds.

Quote ...
File 1: Run the target script wait 10 seconds and call File 2.
File 2: Run target scritpt wait 10 seconds call File 1.
Seems a good idea, but note the call must be don on the server.
I'll try it:-) As I know, CronJob's can't be executed regulary each
ten second or may be my Information false?

Greetings
Reputation Points: 10
Solved Threads: 0
Newbie Poster
maninweb is offline Offline
11 posts
since Jun 2005
May 10th, 2007
0

Re: Run PHP script every 10 seconds

Or you can simply ad
[PHP]header('refresh:10; url=same_page.php');[/PHP]
Reputation Points: 33
Solved Threads: 7
Junior Poster in Training
johny_d is offline Offline
92 posts
since May 2007
May 10th, 2007
0

Re: Run PHP script every 10 seconds

Hi...

Thanks, good idea, can I use a timevalue, like refresh 12:00:xx ?

Greetings
Reputation Points: 10
Solved Threads: 0
Newbie Poster
maninweb is offline Offline
11 posts
since Jun 2005
May 10th, 2007
0

Re: Run PHP script every 10 seconds

Click to Expand / Collapse  Quote originally posted by johny_d ...
Or you can simply ad
[php]header('refresh:10; url=same_page.php');[/php]
Once this is setup and we go to the script URL.
this header() function will active.

Will i run in a continuous loop forever? or only if the script is being viewed by a user.

Secondly, if this is running in a continuous loop.
how can we stop the execution ?

Drag...
Reputation Points: 35
Solved Threads: 5
Junior Poster
dr4g is offline Offline
136 posts
since Apr 2007
May 10th, 2007
0

Re: Run PHP script every 10 seconds

Ir runs only when viewed by a user and will run in continuous loop until the user closes the browser.

Of course, you can setup a $_GET variable to count the loops and stop at some point
Quote ...
Thanks, good idea, can I use a timevalue, like refresh 12:00:xx
As far as I know, in header(refresh...) you can only specify the number of seconds the script has to wait untill refresh, not a certain hour.
Reputation Points: 33
Solved Threads: 7
Junior Poster in Training
johny_d is offline Offline
92 posts
since May 2007
May 10th, 2007
0

Re: Run PHP script every 10 seconds

Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
maninweb is offline Offline
11 posts
since Jun 2005
May 10th, 2007
0

Re: Run PHP script every 10 seconds

You're welcome
Reputation Points: 33
Solved Threads: 7
Junior Poster in Training
johny_d is offline Offline
92 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: mysql_fetch_array(): supplied argument is not a valid MySQL
Next Thread in PHP Forum Timeline: mailer.php almost works :|





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC