On ubuntu 14 I have a super simple file here on my /etc/init/myfile

Inside, it only contains :

start on runlevel [2345]

exec /etc/myfolder/myscript

If I do the same thing on an ubuntu 16 server nothing happens - I assume this is because there are new ways to start things now. Looking at the man pages it looks reasonably complex, multiple files and commands required to set something up. So my question is, what is the simplest and shortest file I can create to ensure my script runs on startup?


Ideally, you'd use a .service file in /etc/systemd/system. (you could probably model after sshd.service.)

Since you specify "simplest and shortest", I'll go with adding /etc/myfolder/myscript right before the exit 0 line in /etc/rc.local.

This is likely to work for the life of 16.04 but unlikely to work with Ubuntu 17.

Additional reference: https://www.freedesktop.org/software/systemd/man/systemd.special.html contains the options for After=

  • I went with this in the end. File here: /etc/systemd/system/myservice.service Content: [Unit] Description=Job that runs the myservice daemon [Service] ExecStart=/etc/somepath/myservice [Install] WantedBy=multi-user.target And then enabled it with: systemctl enable myservice.service A bit more complicated than just two lines in a file like the old way, but it works. Thanks for the help. – Cooker Oct 11 '16 at 9:07

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.