当前位置: 首页 > Linux

linux下设置tomcat服务

时间:2023-04-07 00:47:13 Linux

以centos创建一个tomcat文件,内容如下#!/bin/bash##tomcat的启动脚本#chkconfig:23459060#源函数库。/etc/rc.d/init.d/functions#把这里的tomcat地址改成你的tomcat地址tomcat=/apache-tomcat-7.0.77startup=$tomcat/bin/startup.shshutdown=$tomcat/bin/shutdown.shstart(){echo-n$"启动Tomcat服务:"sh$startupecho$?}stop(){echo-n$"停止Tomcat服务:"sh$shutdownecho$?}restart(){stopstart}status(){ps-aef|grepapache-tomcat|grep-vgrep}#处理不同的输入选项case"$1"instart)start;;stop)stop;;status)status;;restart)restart;;*)echo$"Usage:$0{start|stop|restart|status}"exit1esacexit0复制tomcat文件到/etc/init.d目录下授权cd/etc/init.dchmodu+xtomcatsettomcatasaservicechkconfig--addtomcatsettomcatself-startchkconfigtomcatontry以下命令servicetomcatstartservicetomcatstatusservicetomcatrestartservicetomcatstop