systemctl doesn't recognize my service: Default-Start contains no runlevels, aborting

Solution 1:

I had the same error when porting a sysv script from a redhat box to ubuntu. I needed to add some headers to the script

### BEGIN INIT INFO
# Provides:          my-service-name
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: your description here
### END INIT INFO

found in https://askubuntu.com/questions/909523/default-start-contains-no-runlevels-aborting

Solution 2:

The problem was the location of the file, on Ubuntu server it expects it in /etc/systemd/system, /etc/init.d/ is for legacy files.


Solution 3:

Just to add on to the answer from @CharlesB - when I got into this state I was able to simply move the file from /etc/init.d/ to /etc/systemd/system/ and rerun the command and it worked properly:

sudo mv /etc/init.d/mydaemon /etc/systemd/system/
sudo systemctl enable mydaemon

Tags:

Ubuntu

Systemd