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 @   Posion゜  阅读(310)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下
点击右上角即可分享
微信分享提示