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

  • 1
    What version of Ubuntu are you running?
    – voretaq7
    Commented Nov 15, 2012 at 21:57

3 Answers 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]


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.

  • ...what if he's running a pre-upstart version of Ubuntu? :)
    – voretaq7
    Commented Nov 15, 2012 at 21:57
  • 1
    @voretaq7 Then he should upgrade, because the last version that didn't have Upstart was 6.06LTS (dapper), which stopped being supported in 2009 (2011 for servers). Commented Nov 16, 2012 at 12:24
  • Prior to 10.04LTS (lucid), the Upstart directory was /etc/event.d/, but those versions are also no longer supported. Here's a handy resource for Ubuntu end-of-life dates. Commented Nov 16, 2012 at 12:33

Non-Upstart systems

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

The basic format is


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.

  • For completeness, one of the most common init schemes is sysvinit, which consists of scripts in /etc/init.d/, symlinked from the appropriate /etc/rc[RUNLEVEL].d/, frequently configured with update-rc.d. Commented Nov 16, 2012 at 12:28

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

  • op is talking about respawn from init. You can't kill init. You can do what the accepted answer says, or on SystemV system, edit inittab, then init q or telinit q
    – papo
    Commented Dec 20, 2020 at 14:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .