I'm configuring a Java app to run at boot using jsvc, following this tutorial which uses systemv (init.d). I'm running Ubuntu 16.04, which uses systemd, and am having a hard time finding exactly what I need to do to have it run at boot, and stop at shutdown.

So far I know I need to create a service with Type=forking as the jsvc_exec command which starts/stops the app forks once it has run.

What else do I need to include to have it work in a similar way to the systemv script from the tutorial?



Something like this:

 Description=Description of daemon


 ExecStart=/path/to/program/program start
 ExecStop=/path/to/program/program stop

  • This is exactly what I was looking for, thanks! One quick question, what is the PIDFile and where would I find it? Or does it not matter because the # comments the line? – Luke Moll Sep 3 '16 at 15:28
  • #comments the line, uncomment what you need – Alex Sep 3 '16 at 15:29
  • in the Arch wiki it said if it's specified systemd can keep track of the main process, if I wanted to include this where would I find the PID file? – Luke Moll Sep 3 '16 at 15:31
  • 1
    /var/run/mydaemon.pid I guess, from what I read in the tutorial... – Alex Sep 3 '16 at 15:33
  • 1
    Don't forget to sudo systemctl enable daemon.service where you replace daemon.service with the name of your service file, or it won't start at boot :) – Alex Sep 3 '16 at 15:37

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.