Linux Centos 7 systemctl(systemd)新增加service服务,并且开机启动

centos 7中采用了systemd控制系统服务,更加简单,以前启动服务需要 service xxxx start|stop等。现在需要的是systemctl start|stop xxx。比如我配置的启动tomcat,systemctl start tomcat。十分方便。以前是在,现在直接在/usr/lib/systemd/system里面新建一个tomcat.service,内容如下:

[Unit]  
Description=tomcatapi  
After=network.target  
   
[Service]  
Type=forking  
ExecStart=/usr/local/soft/tomcat/tomcat8/bin/startup.sh  
ExecReload=  
ExecStop=/usr/local/soft/tomcat/tomcat8/bin/shutdown.sh  
PrivateTmp=true  
   
[Install]  
WantedBy=multi-user.target 

然后给这个tomcat.service 文件chomod +x权限即可!最后在重启下systemctl,命令如下: systemctl daemon-reload
最后就可以通过systemctl start tomcat启动啦!

原文链接:https://blog.csdn.net/qq_25821067/article/details/79120222

posted @ 2021-09-27 09:39  Posion゜  阅读(304)  评论(0编辑  收藏  举报