I am having a hard time making my systemd script to run in Ubuntu 16.04. Could someone help me checking if I am doing something wrong?

This is the script:


ExecStart="java -Xmx2048m -Xms512m -jar /opt/project/target/test-dl-1.0.1-SNAPSHOT.jar server /opt/project/src/main/resources/config/config.yml"


And I save it to /lib/systemd/system/ , then I run systemctl daemon-reload and then systemctl enable myservice.service

However, the output I see from systemctl status myservice.service is:

Aug 17 14:59:17 ubuntu-8gb-sfo2-01 systemd[1]: [/lib/systemd/system/myservice.service:7] Executable path is not absolute, ignoring: 
Aug 17 14:59:17 ubuntu-8gb-sfo2-01 systemd[1]: myservice.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.

Are you guys seeing anything wrong that I am doing? Btw, I also tried to not use quotes in the ExecStart part and I get the same error.

Thanks in advance for your help.

  • What happens if you replace "java" by it's absolute path as the log suggests? "which java" or "whereis java" on console might show you this path. – mm759 Aug 17 '16 at 15:15
  • Thanks. Now I get a different error: Service has no ExecStart= setting, which is only allowed for RemainAfterExit=yes services. Refusing. – Jordi Mares Soler Aug 17 '16 at 15:20
  • What about additionally dropping the quotes? I don't saw quotes in some other unit files that I checked and I don't recognize what they are needed for. – mm759 Aug 17 '16 at 19:35

The program you are starting with ExecStart must have full path. Find out where your java binary is and add that to the ExecStart.

Ex: ExecStart=/bin/java .....

  • 1
    This has been changed in recent versions of systemd. – Umut Feb 27 '19 at 14:50
  • as Umut says, this no longer helps. – jcomeau_ictx Apr 6 '20 at 22:26

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.