自定义systemctl服务

systemctl

Systemd: 系统守护(daemon)

文件后缀.service 用于定义系统服务 [.target,.device,.mount,.socket]

服务目录 /usr/lib/systemd/system/

命令

systemctl status name.service
systemctl start name.service
systemctl stop name.service
systemctl restart name.service

systemctl daemon-reload

添加tomcat服务

* vi catalina.sh; 添加 export JAVA_HOME
* touch tomcat.service
* cp tomcat.service /usr/lib/systemd/system/tomcat.service
## vi tomcat.service
[Unit]
Description=ecsweb tomcat
After=ecsweb.service

[Service]
Type=forking
User=root
Group=root
ExecStart=/usr/local/deploy/datafs/tomcat/apache-tomcat-9.0.37/bin/startup.sh
ExecReload=
ExecStop=/usr/local/tomcat/bin/shutdown.sh
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target
posted @ 2020-08-27 09:11  pengsn  阅读(300)  评论(0编辑  收藏  举报