A Linux daemon written in Java locations
I’m currently writing the Java daemon. I’m writing a script with standard daemon commands (start, stop, restart, state) and I’m trying to figure out where I should go when installing the daemon.
My current thoughts are:
PID file: /var/run/myapp.pid
Daemon script: /etc/init.d/myapp
Java application (.jar): /usr/bin/myapp
Log /var/log/myapp.err, /var/log/myapp.log, /var/log/myapp.info (you know
).
Configs: /etc/myapp.conf (or /etc/myapp/configs-go-here if I have more than one in the future).
I’m still new to Linux directory structures, so please let me know if I’m doing something wrong. What confuses me the most is that my Java application is an .jar file (archive) and not a binary. So does this mean that /usr/bin/ is not its “right” position?
Solution
You can put the .jar file into /usr/lib/myapp/myapp.jar
and have the startup script execute java -j/usr/lib/myapp/myapp
.jar
From that side, jar is actually a library used by the /usr/bin/java
binary, so those locations are fine for me.