I've wrapped a jar in a init.d service following the guide here.

  • created the service file under /etc/init.d/
  • give proper permissions
  • test the stop and start: sudo service myservice start/stop/restart;

The process is starting after the sudo service myservice start and I can see it from the command ps -ef | grep -i myservice However the service should log its execution in a logging file in the same path of the jar, but this logging file is not created.

Instead, If the jar is executed through java -jar myJar.jar & and not within the service the log file is created.

How is it possible?

Thanks Simone

closed as unclear what you're asking by Rui F Ribeiro, sebasth, user88036, Thomas, Shadur Oct 8 '18 at 13:44

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Does the user account which is running the java program have read-write access to the log file? – Emmanuel Rosa Oct 8 '18 at 7:38
  • 1
    That wrapper appears to be only for creating a pid/starting a java program, and you v talk nothing about what you are doing to generate logs. Have you also did the modification there – Rui F Ribeiro Oct 8 '18 at 7:59
  • 1
    You are asking people to debug the arbitrary coded behaviour of a program that they do not know, with zero information about that program. Answerers do not know all of the things that a program's built-in idiosyncratic logging system might be sensitive to. That's not a particularly good van Smoorenburg rc script example to be following, either. – JdeBP Oct 8 '18 at 8:02
  • @EmmanuelRosa by the looks of the unit, root. – Rui F Ribeiro Oct 8 '18 at 8:04
  • 1
    (And its supposed systemd update is an example of how not to run Java services under systemd, incorporating at least two of the House of Horror mistakes.) – JdeBP Oct 8 '18 at 8:06

Browse other questions tagged or ask your own question.