5

I like to respawn a service when the service goes down. I have added it to inittab however I cannot kill it when i need to.

Is there away i can respawn a service however be able to kill it manually when i need to.

thanks in advance

super2442804
  • 53
  • 1
  • 5

3 Answers3

3

Ubuntu has switched to Upstart for its init daemon, so the best way would be to make an Upstart job file in /etc/init/. Here's an example:

description "My important service"

start on filesystem or runlevel [2345]
stop on runlevel [!2345]

respawn

exec /usr/bin/mydaemon --some-args

If this file is saved as /etc/init/myjob.conf, it will create a job that starts at boot, respawns when it dies, and can be manually stopped (as root) with stop myjob, service myjob stop, or initctl stop myjob.

bonsaiviking
  • 4,490
1

Non-Upstart systems

Old-school use of /etc/inittab. http://unixhelp.ed.ac.uk/CGI/man-cgi?inittab+5

The basic format is

<uniqueid>:<runlevel>:<action>:<command>

Upstart systems

Modern use of .conf files in /etc/init/: http://linux.die.net/man/5/init

The inittab method from above will still work.

Jeff Ferland
  • 20,987
0

I have tried solutions presented in previous answers, but it didn't work for my version of Teamviewer 9. The only way how to stop teamviewerd from respawning was this:

killall -9 teamviewerd

Frodik
  • 293