Max Min
Max Min

Reputation: 121

How to respawn PHP script using upstart?

I have an Ubuntu 12.04 installation and a PHP script I want to re-run as soon as it terminates. I'm using upstart and this myscript.conf in /etc/init/:

start on startup
stop on shutdown
exec php5 /var/myscript.php
respawn

I can run my script using start myscript, which works fine one-time, but I can't get the script to respawn once it terminates.

Is there something special I have to pay attention to when trying to respawn a PHP script?

Upvotes: 2

Views: 1891

Answers (1)

René Höhle
René Höhle

Reputation: 27285

You can update your script very easy when you have a startscript under /etc/init.d

update-rc.d myscript defaults

But then you need a startscript. You can checkout the skeleton script (/etc/init.d/skeleton) and copy the script. Then you can change the params and run your programm.

like this: /etc/init.d/myscript start

In the startscript you can kill the process if its not terminating correct.

Upvotes: 2

Related Questions