生活随笔 2012-12-14
方式有两种:
1.使用chkconfig
2.在/etc/rc.d/rc.local中加入
方法一:
vi myservice
myservice内容如下:
#
#tomcat:Start/Stop/Restarttomcat
#
#chkconfig:23458020
#description:TomcatisaJavaServletContainer
#
#
#matchthesevaluestoyourenvironment:
exportCATALINA_BASE=/home/app/bmp/apache-tomcat-6.0.35
exportCATALINA_HOME=/home/app/bmp/apache-tomcat-6.0.35
exportCATALINA_TMPDIR=/home/app/bmp/apache-tomcat-6.0.35/temp
exportJRE_HOME=/root/softpkg/jdk1.6.0_29
exportJAVA_HOME=/root/softpkg/jdk1.6.0_29
exportCLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
exportPATH=$PATH:$JAVA_HOME/bin
#Sourcefunctionlibrary.
./etc/rc.d/init.d/functions
TOMCAT=/home/app/bmp/apache-tomcat-6.0.35
start(){
echo"-n___FCKpd___0quot;StartingTomcat:"
$TOMCAT/bin/catalina.shstart
}
stop(){
echo"-n___FCKpd___0quot;StoppingTomcat:"
$TOMCAT/bin/catalina.shstop
}
#Seehowwewerecalled.
case"$1"in
start)
start
;;
stop)
stop
;;
status)
;;
status)
;;
restart)
stop
start
;;
*)
echo"___FCKpd___0quot;Usage:$0{start|stop|restart}"
;;
esac
exit $RETVAL将myservice存入/etc/rc.d/init.d/
cp myservice /etc/rc.d/init.d/
执行命令:
chkconfig --add myservice
用chkconfig --list可以查看
方法二:
vi myservice.sh
myservice.sh内容如下:
exportJAVA_HOME=/root/softpkg/jdk1.6.0_29
exportCLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
exportPATH=$PATH:$JAVA_HOME/bin
exportCATALINA_HOME=/home/app/bmp/apache-tomcat-6.0.35
/home/app/bmp/apache-tomcat-6.0.35/bin/catalina.sh start将myservice.sh的路径写在/etc/rc.d/rc.local中
vi /etc/rc.d/rc.local