NYCPHP Meetup

NYPHP.org

[nycphp-talk] Run PHP script as service (every 10 seconds)

Rolan Yang rolan at omnistep.com
Tue Dec 16 10:15:13 EST 2008


hafez ahmad wrote:
> Dears,
>
> I need to run PHP script every 10 seconds , I can do that with (while 
> true) and sleep(10), but I need to the script always run on Linux 
> machine as service.
>
> Any Ideas?
>
While not as elegant as some of the other suggestions above, you could 
run "screen" to create a virtual terminal that remains active (even when 
you log off), then use the "watch" command to run a script every x 
seconds like so:

watch -n 10 ./myphpscript

Use CTRL-A D to drop out of the screen terminal and leave it running in 
the background.

~Rolan



More information about the talk mailing list