Atm, I need to randomly start and stop (for lack of a better word in my mind) a job. I start it by typing java -jar foo.jar
and to stop it find out its pid and kill it. Killing it doesn't cause any data loss or corruption or anything, just FYI. Its tedious to do both these steps because the first command has to be executed from a particular directory, ie /usr/share/jetty
(The kill can be executed from anywhere).
So I was thinking something on the lines of
service foo start
and service foo stop
to start and stop services. Is that possible, and more importantly correct? Is there any other solution?
Thanks.
Best Answer
Yeah Upstart is a pretty good option for this. Just create a new file:
You can change the filename to whatever you like but then stick this in it:
Some notes about that, I'm
su
ing to nobody for security. You might need it tosu
into another account but it's probably not recommended that it runs asroot
.