标签:tin null startup com and java_home list network 停止
CentOS7开始,从/etc/init.d脚本改为了systemctl管理服务。
本文记录了把tomcat9加入systemd管理的步骤。
# cd /usr/local/tomcat//usr/local/tomcat/apache-tomcat-9.0.21/bin
# ls
编辑 catalina.sh脚本文件
# vim catalina.sh
# Get standard environment variables
PRGDIR=`dirname "$PRG"`
# Only set CATALINA_HOME if not already set
[ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
# Copy CATALINA_BASE from CATALINA_HOME if not already set
[ -z "$CATALINA_BASE" ] && CATALINA_BASE="$CATALINA_HOME"
#添加的pid
# setting tomcat.pid
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
# cd /usr/lib/systemd/system
# vim tomcat.service
文件内容
##########################################################
[Unit]
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment="JAVA_HOME=/usr/local/java/jdk1.8.0_211"
Environment="CATALINA_HOME=/usr/local/tomcat/apache-tomcat-9.0.21"
PIDFile=/usr/local/tomcat/apache-tomcat-9.0.21/tomcat.pid
ExecStart=/usr/local/tomcat/apache-tomcat-9.0.21/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
##########################################################
# systemctl daemon-reload
启动tomcat服务
systemctl start tomcat.service
设置开机自启动
systemctl enable tomcat.service
停止开机自启动
systemctl disable tomcat.service
查看服务当前状态
systemctl status tomcat.service
重新启动服务
systemctl restart tomcat.service
查看所有已启动的服务
systemctl list-units --type=service
centos7 使用systemctl设置tomcat9服务
标签:tin null startup com and java_home list network 停止
原文地址:https://www.cnblogs.com/ethanw97m/p/11328268.html