Link to home
Start Free TrialLog in
Avatar of spandor
spandor

asked on

Creating a daemon on Unix server to keep running PHP script.

Hi

I have a PHP script which usualy I start from command line by writing: php picker.php.
And that works.
However, I'd like to create a daemon in order to have this script working all the time. How I can do this??
Avatar of alakani
alakani

One option may be to use the "cron" utility to schedule the script to run periodically.  Based on how long the script takes to run, you can set any interval you like, say every 5 minutes, or every hour.

If the script itself has a built-in execution loop, i.e. if it never exits when left by itself, then you can write a shell script that will manage the script as a service, making sure it starts when the server boots, and to restart it if it dies.

Please let me know if you'd like more information on either of these options.

Thanks!
Avatar of spandor

ASKER

Hey.

Thanks for the replay, options 2 sounds good for me :)

ASKER CERTIFIED SOLUTION
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial