Java – how to write init scripts
•
Java
Hi, I'm using 64 bit Fedora 10 Linux I have created a sample Java application Now I want to write an init script for the application So my application should start at startup
How to write init script to start at startup
Thank you, Sunil Kumar sahoo
Solution
Here's a good guide:
http://www.novell.com/coolsolutions/feature/15380.html
I suggest taking a look at Tomcat startup SH and shutdown SH script, and then modify the following init d script:
#!/bin/bash # # tomcat # # chkconfig: # description: Start up the Tomcat servlet engine. # Source function library. . /etc/init.d/functions RETVAL=$? CATALINA_HOME="/usr/apps/apache/tomcat/jakarta-tomcat-4.0.4" case "$1" in start) if [ -f $CATALINA_HOME/bin/startup.sh ]; then echo $"Starting Tomcat" /bin/su tomcat $CATALINA_HOME/bin/startup.sh fi ;; stop) if [ -f $CATALINA_HOME/bin/shutdown.sh ]; then echo $"Stopping Tomcat" /bin/su tomcat $CATALINA_HOME/bin/shutdown.sh fi ;; *) echo $"Usage: $0 {start|stop}" exit 1 ;; esac
The above script lacks many things to make it fully compliant with Linux standard base You may want to copy the existing init. Net from the distribution D script A slightly better script can be found here: http://blog.valotas.com/2011/05/tomcat-initd-script.html
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码