Run PHP script every 10 seconds

Reply

Join Date: Jun 2005
Posts: 11
Reputation: maninweb is an unknown quantity at this point 
Solved Threads: 0
maninweb maninweb is offline Offline
Newbie Poster

Run PHP script every 10 seconds

 
0
  #1
May 9th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Run PHP script every 10 seconds

 
0
  #2
May 9th, 2007
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.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

Re: Run PHP script every 10 seconds

 
0
  #3
May 9th, 2007
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.
GardCMS :: Open Source CMS :: Gardcms.org
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 11
Reputation: maninweb is an unknown quantity at this point 
Solved Threads: 0
maninweb maninweb is offline Offline
Newbie Poster

Re: Run PHP script every 10 seconds

 
0
  #4
May 10th, 2007
Hi...

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

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
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 68
Reputation: johny_d is an unknown quantity at this point 
Solved Threads: 4
johny_d's Avatar
johny_d johny_d is offline Offline
Junior Poster in Training

Re: Run PHP script every 10 seconds

 
0
  #5
May 10th, 2007
Or you can simply ad
[PHP]header('refresh:10; url=same_page.php');[/PHP]
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 11
Reputation: maninweb is an unknown quantity at this point 
Solved Threads: 0
maninweb maninweb is offline Offline
Newbie Poster

Re: Run PHP script every 10 seconds

 
0
  #6
May 10th, 2007
Hi...

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

Greetings
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

Re: Run PHP script every 10 seconds

 
0
  #7
May 10th, 2007
Originally Posted by johny_d View Post
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...
GardCMS :: Open Source CMS :: Gardcms.org
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 68
Reputation: johny_d is an unknown quantity at this point 
Solved Threads: 4
johny_d's Avatar
johny_d johny_d is offline Offline
Junior Poster in Training

Re: Run PHP script every 10 seconds

 
0
  #8
May 10th, 2007
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
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 11
Reputation: maninweb is an unknown quantity at this point 
Solved Threads: 0
maninweb maninweb is offline Offline
Newbie Poster

Re: Run PHP script every 10 seconds

 
0
  #9
May 10th, 2007
Thanks
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 68
Reputation: johny_d is an unknown quantity at this point 
Solved Threads: 4
johny_d's Avatar
johny_d johny_d is offline Offline
Junior Poster in Training

Re: Run PHP script every 10 seconds

 
0
  #10
May 10th, 2007
You're welcome
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC