Setup Systemd Service on Ubuntu 16.04

$ sudo vim /etc/systemd/system/myservice.service [Unit] Description=Run the service [Service] User=ubuntu # change the workspace WorkingDirectory=/usr/local/src #path to executable. #executable is a bash script which calls jar file ExecStart=/usr/local/src/somescript SuccessExitStatus=143 TimeoutStopSec=10 Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target $ sudo vim /usr/local/src/somescript #!/bin/sh java -jar /some/file.jar sudo systemctl daemon-reload sudo systemctl enable myservice.service sudo systemctl start myservice sudo systemctl … Read more