当前位置: 首页 > 图文教程 > 服务器 > Linux服务器 > 在SUSELinux将Tomcat作为Service运行

Linux服务器
在虚拟机RedhatLinux下安装Samba服务器
Linux系统下服务器硬件检查和文件传输
LinuxFtp服务器搭建支持Anonymous读写
Linux操作系统下Vsftp配置使用详细解析
Linux服务器的常用备份方法
SUSELinuxsubversion服务器自启动
RHEL下DHCP服务的配置与应用
linux自带的MAIL客户端用法
用NFS服务开发ARMLinux程序的方法
新手学堂:在Linux系统下mail命令的测试
UbuntuLinux系统下ApacheSSL配置方法
为Solaris服务器配置开源安全工具(下)
在Linux系统环境下配置WU-FTP服务器
Redhatlinux自动FTP传送备份
UbuntuLinux6.06LTS下安装Samba服务
在Centos5安装配置VNC的方法详细介绍
FedoraLinux8配置SAMBA服务的过程
Linux下成功安装和配置Sock5代理过程
实用技巧:Linux系统服务器快速登录
UbuntuServer系统用户安全优化方法

Linux服务器 中的 在SUSELinux将Tomcat作为Service运行


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-18   浏览: 37 ::
收藏到网摘: n/a

SUSELinux没有rc.local
 
  一、创建启动/停止脚本文件
 
通过一下脚本,可以使Tomcat以Service方式运行。
 

#!/bin/bash#chkconfig:23451090#description:StartsandStopstheTomcatdaemon.TOMCAT_HOME=/usr/local/apache-tomcat-5.5.12TOMCAT_START=$TOMCAT_HOME/bin/startup.shTOMCAT_STOP=$TOMCAT_HOME/bin/shutdown.sh#necessaryenvironmentvariablesexportCATALINA_HOME=$TOMCAT_HOMEexportJAVA_HOME=/usr/java/jdk1.5.0_05#sourcefunctionlibrary../etc/rc.d/init.d/functions#sourcenetworkingconfiguration../etc/sysconfig/network#checkthatnetworkingisup.["${NETWORKING}"="no"]&&exit0#checkfortomcatscriptif[!-f$TOMCAT_HOME/bin/catalina.sh]thenecho"Tomcatnotvalilable..."exitfistart(){echo-n"StartingTomcat:"daemon$TOMCAT_STARTechotouch/var/lock/subsys/tomcat}stop(){echo-n$"ShuttingdownTomcat:"daemon$TOMCAT_STOPrm-f/var/lock/subsys/tomcat.pidecho}restart(){stopstart}status(){psax--width=1000|grep"[o]rg.apache.catalina.startup.Bootstrapstart"|awk'{printf$1""}'|wc|awk'{print$2}'>/tmp/tomcat_process_count.txtreadline</tmp/tomcat_process_count.txtif[$line-gt0];thenecho-n"tomcat(pid"psax--width=1000|grep"org.apache.catalina.startup.Bootstrapstart"|awk'{printf$1""}'echo-n")isrunning..."echoelseecho"Tomcatisstopped"fi}case"$1"instart)start;;stop)stop;;restart)stopsleep3start;;status)status;;*)echo"Usage:tomcatd{start|stop|restart|status}"exit1esacexit0



二、保存并设置脚本文件

将以上的脚本文件保存在/etc/init.d中,命名为tomcat;

设置tomcat的文件属性

#chmoda+xtomcat

三、设置服务运行级别

最后用chkconfig设置服务运行

#chkconfig--addtomcat

注意:

在tomcat文件的头两行的注释语句中,需要包含chkconfig和description两部分内容(确认不要拼写错误,),否则在执行“chkconfig--addtomcat”时,会出现“tomcat服务不支持chkconfig”的错误提示。

chkconfig这行表示缺省启动的运行级别以及启动和停止的优先级,如该服务缺省不再任何运行级启动,则以-代替运行级别。在tomcat中表示脚本在运行级2、3、4、5启动,启动优先权为10,停止优先权为90。

description行对服务进行描述,可以用“\”跨行注释。