0

At the moment I have a daemon starting at boot using rc.local by the following line.

su -l user -c '/dir/daemon'

but I would like to start this process as a service with respawn. I found out that it should be added to /etc/inittab with something like

daemon:run-level:respawn:script-to-daemon
  1. which run level should I use?
  2. how do I have it executed as user?
  3. if I'm using inittab should I remove the line in rc.local
  4. is there something like forever that'll do this for me
0

Forget about /etc/inittab.

If you have Ubuntu with upstart, or one of the systemd operating systems, then your system completely ignores /etc/inittab and it is a complete irrelevance.

Forget about runlevels.

They exist in systemd operating systems, but only as compatibility shims. The systemd documentation states that the concept is "obsolete". If you're starting with this on a systemd operating system, don't start there.

Forget about forever.

If you have a service manager, be it runit, systemd, perp, nosh, upstart, s6, or daemontools-encore, then it's already doing what you think you need forever for.

Take your stuff out of rc.local.

On an upstart or systemd system it's really as much of a compatibility shim as runlevels are.

Put your stuff into an upstart job or a systemd service unit.

The latter would look something like

[Unit]
Description=Start the wibble daemon

[Service]
User=wibble-d
ExecStart=/usr/local/bin/wibbled
Restart=always

[Install]
WantedBy=multi-user.target
  • Thanks, but systemd or upstart is not an option, the system in question is running lenny, and updating is a huge pain (its a vortex86 processor and the manufacturer provided patched kernel recommends debian 5) instead of going in to a partial upgrade, I'd rather figure out how to use inittab. – Kuravi H Jun 26 '15 at 2:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.