- 创建服务基本概念:https://www.cnblogs.com/mafeng/p/10316351.html
- tomcat启动脚本:https://blog.csdn.net/zxnlmj/article/details/22933477
#!/bin/bash # This is the init script for starting up the # Jakarta Tomcat server # # chkconfig: 345 91 10 # description: Starts and stops the Tomcat daemon. # # Source function library. . /etc/rc.d/init.d/functions # Get config. . /etc/sysconfig/network # Check that networking is up. [ "${NETWORKING}" = "no" ] && exit 0 export JAVA_HOME=/usr/jdk/jdk1.8.0_131 tomcat_home=/usr/tomcat/apache-tomcat-9.0.34 startup=$tomcat_home/bin/startup.sh shutdown=$tomcat_home/bin/shutdown.sh start(){ echo -n "Starting Tomcat service:" cd $tomcat_home $startup echo "tomcat is succeessfully started up" } stop(){ echo -n "Shutting down tomcat: " cd $tomcat_home $shutdown echo "tomcat is succeessfully shut down." } status(){ numproc=`ps -ef | grep catalina | grep -v "grep catalina" | wc -l` if [ $numproc -gt 0 ]; then echo "Tomcat is running..." else echo "Tomcat is stopped..." fi } restart(){ stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status ;; restart) restart ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 1 esac
创建服务:https://blog.csdn.net/weixin_33747129/article/details/91700921
3.注意事项:
-
- sh文件头部必须以#!bin/sh或者#!bin/bash开头
- 服务运行的脚本文件 需要自行在头部增加环境变量