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?


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 using update-rc.d to enable your daemon, use the systemd native command equivalent:

sudo systemctl enable mydaemon

If this still produces the same error, add the missing lines to the starting set of comments in your script:

# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6

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 with

sudo systemctl start mydaemon

and ask for its status with

sudo systemctl status -l mydaemon

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.

  • Ah thank you. I'd inadvertantly done this as I'd made a new systemd script in /usr/systemd but still came up with these errors. I figured since the systemd script referenced the systemv one, that's why it was causing the errors and so I added these lines in the systemv script. Didn't realise systemd was automatically converting systemv scripts into systemd ones.
    – Luke Moll
    Sep 3 '16 at 18:18
  • see wiki.debian.org/LSBInitScripts
    – nick fox
    Feb 14 '18 at 11:32

You must have a /etc/init.d/tightvncserver script like this:

# Provides:          tightvncserver
# Should-Start:      
# Required-Start:    $local_fs $remote_fs x11-common
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: VNC server
# Description:       Debian init script for the VNC Server
# /etc/init.d/tightvncserver

# Set the VNCUSER variable to the name of the user to start tightvncserver under
case "$1" in
    su $VNCUSER -c '/usr/bin/tightvncserver :1 -geometry 1280x800 -depth 16'
    echo "Starting TightVNC server for $VNCUSER"
    pkill Xtightvnc
    echo "Tightvncserver stopped"
    echo "Usage: /etc/init.d/tightvncserver {start|stop}"
    exit 1
exit 0

and then run the command:

sudo service tightvncserver start

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.