CentOS7 添加系统服务(systemctl)

1.目录
/usr/lib/systemd/system

2.添加文件(*.service),以Tomcat为例:
[Unit]
Description=test
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/home/apache-tomcat/tomcat.pid
ExecStart=/home/apache-tomcat/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

3.单服务操作|
systemctl start/stop/restart *.service

4.添加到开机启动
systemctl enable *.service

5.移除开机启动
systemctl disable *.service

你可能感兴趣的:(CentOS7)