Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
systemd example - works on Ubuntu 16.04

Ubuntu 16.04 systemd service setup

Enable persistent user systemd services

loginctl enable-linger $user

Create a user systemd directory

mkdir ~/.config/systemd/user

Create a systemd configuration

touch my-service.service

Example service


ExecStart=/usr/bin/java -jar /home/user/my-service.jar

# *use this if you want to start on boot*

For more info and details of options checkout this

Reload the user daemon (this must be done on every change to your service file)

systemctl --user daemon-reload

Starting and or stop your service as needed

systemctl --user [start|stop|restart] my-service

zsiegel commented Mar 21, 2017

If you are having trouble getting things to work on boot checkout this

$ systemctl --user disable my-service
$ systemctl --user daemon-reload
$ systemctl --user enable my-service

zsiegel commented Mar 21, 2017

To check if your user service is setup as a target of boot use

systemctl --user list-dependencies

zsiegel commented Mar 21, 2017

Also see this systemd github issue for debugging help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment