I have a Java executable program that I can run by typing
java -jar abc.jar in terminal.
How can I run it as a service? I want to run it as a service like by typing
service abc start.
Upstart scripts have to placed at
Basically they require 2 sessions: one to indicate when to start, and another with the command to exec.
The easiest script to start with your sample is:
Of course, created as root under
If your script requires more than one command line, use the
To enable bash completion for your service, add a symlink into
Then try start and stop it:
Of course, if you read the upstart cookbook, you can create
And, additionally, I read you want to check if a process is running. Check this question and maybe use the
You need to create an upstart. http://upstart.ubuntu.com/getting-started.html
Upstart is (IMHO) a disaster compared to good ol' SysV init scripts. Upstart is FAR more effort with little upside to the added work. With that said, I suspect there will be a few upstart defenders out there that will take me to task for me stating the obvious ;-)
I can give you some best alternative than that, that is using alias. Its rather easier than doing
you can simply call it everytime when ever you want with
then at the end type a line as
Then save and close the file.
Then restart the bash with
Now if you type abc in your terminal automatically it will access the jar file you have given.