respawn service Debian Jessie without inittab

3.5k Views Asked by At

I've installed the last stable version of Debian (Jessie) and /etc/inittab doesn't exist. I have read the new init system is called Sysv. I need to launch a service with parameter, I used to add a line in inittab like u1:23:respawn:/etc/init.d/my_service foreground

I'm trying to add this one with sysvrc-conf -p but I don't know how...

How can I do that without inittab? Thank you so much.

1

There are 1 best solutions below

0
admirableadmin On

Found this question by google, maybe someone else finds this usefull: The new init system for Debian Jessie is systemd. The old way in Debian Wheezy was Sysv with /etc/inittab.

To create a respawn service with systemd just create a file in /etc/systemd/system/ i.e. mplayer2.service

[Unit]
Desription=mplayer with systemd, respawn
After=network.target

[Service]
ExecStart=/usr/bin/mplayer -nolirc -ao alsa -vo null -really-quiet http://stream.sunshine-live.de/hq/mp3-128/Facebook-og-audio-tag/
Restart=always

[Install]
WantedBy=multi-user.target

and activate it

systemctl enable mplayer2.service

reboot or start it manually

systemctl daemon-reload
systemctl start mplayer2.service

If you reboot or kill the process, it will be restarted automatically some seconds later.