Converting your Web App jar into Daemon Service in linux
Posted By : Prashank Jauhari | 22-Sep-2017
Linux Shell Script Code to create daemon service of a jar is as under. There is also link to shell script file at the bottom of the blog.
Most of the Code is self-explanatory.
Step to create Daemon
Step 1) In the Source code above replace the value of PATH_TO_JAR and PID_PATH_NAME and SERVICE_NAME variables with your jar path (path should be absolute), the name of the file(with absolute path) that will be created to store process id for your jar and name that you want to give your service.
Step 2) In Step 2 copy above file inside /etc/init.d folder
It is the folder where all daemon services are stored.
Command for that is :sudo cp "file path of your service file" /etc/init.d/
Now you are all set.
Command for starting, restarting, stopping and fetching the status of service is as under
1) sudo service myservice start
2)sudo service myservice restart
3)sudo service myservice stop
4)sudo service myservice status
You can download above script file from here. https://s3.amazonaws.com/oodles-blogs/blog-images/aa592953-4dae-4829-8ed4-f8965e35c5fe.null
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Prashank Jauhari
Prashank is quick learner and passionate about new technologies. He is currently working as Java Developer with knowledge of Spring and Hibernate.