Linux服务自启动的方式有多种,有时候无法通过chkconfig命令运行级别设置和ntsysv图形运行级别设置时,此下方法可以有效解决问题。
生产环境:
OS:CentOS release 6.7 (Final)
Web服务器:Apache Tomcat/7.0.57
任务:Linux启动时需要自动启动Tomcat服务。
Linux自动启动服务配置方式如下:
[[email protected]~]# cd /etc/rc.d
#!/bin/sh
#
# This script will beexecuted *after* all the other init scripts.
# You can put your owninitialization stuff in here if you don‘t
# want to do the full Sys Vstyle init stuff.
touch /var/lock/subsys/local
/usr/local/tomcat/bin/startup.sh #随系统自动启动tomcat服务
/usr/local/apache2/bin/apachectlstart
手动启动Tomcat服务方式如下:
[[email protected] ~]# cd /usr/local/tomcat
[[email protected] bin]#./shutdown.sh #关闭tomcat服务
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.7.0_71
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[[email protected] bin]#./startup.sh#启动tomcat服务
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.7.0_71
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
原文:http://sky9896.blog.51cto.com/2330653/1733086