I'm writing a daemon to manage my Java app on a headless Ubuntu 16.04 box using jsvc and this (probably pre-systemd) tutorial, and got as far as running update-rc.d mydaemon enable
, receiving the error
update-rc.d: error: mydaemon Default-Start contains no runlevels, aborting
Having Googled around a bit this appears to have something to do with the (fairly?) recent move to systemd
, which I have confirmed is running with pidof systemd
.
How do I achieve the same starting-at-boot behaviour as update-rc.d
(and more importantly stopping the service via /etc/init.d/mydaemon stop
rather than just killing the process as the Java app needs to clean up). And are systemd
and update-rc.d
different systems, or does systemd
just change how the latter works?
Best Answer
I don't have a Ubuntu 16.04 to test this on, or provide you with many details, but systemd has a compatibility feature to allow older
/etc/init.d
scripts to continue working. Instead of usingupdate-rc.d
to enable your daemon, use the systemd native command equivalent:If this still produces the same error, add the missing lines to the starting set of comments in your script:
between the
### BEGIN INIT INFO
and### END INIT INFO
lines, and try again. See the LSB core description for these lines. You can also explicitly start the daemon withand ask for its status with
See
man systemd-sysv-generator
for the compatibility feature. See this wiki for converting System V or upstart scripts like yours to native systemd Units.