分类目录

链接

2019 年 9 月
 1
2345678
9101112131415
16171819202122
23242526272829
30  

近期文章

热门标签

新人福利,免费薅羊毛

现在位置:    首页 > LINUX > 正文
CentOS 7将linux服务加入系统启动 systemd service
LINUX 暂无评论 阅读(230)

直接上代码,这是服务例子:

  1. [Unit]
  2. Description="xxx.service"
  3. [Service]
  4. Type=simple
  5. GuessMainPID=true
  6. WorkingDirectory=/www/wwwroot/www.natureyogas.com/admin/
  7. StandardOutput=journal
  8. StandardError=journal
  9. ExecStart=/usr/bin/dotnet /www/wwwroot/www.natureyogas.com/admin/Yoga.dll
  10. Restart=always
  11. [Install]
  12. WantedBy=multi-user.target

使用方法:
将以上指令保存为xxx.service。(后缀为service)
mv xxx.xerver /usr/lib/systemd/system/    #【将ngrok.service拷贝到该目录】
systemctl enable xxx.service                          #【加入开机自启】
systemctl daemon-reload                               #【重新载入 systemd,扫描新的或有变动的单元】 or systemctl start xxx.service

----------------------------------扩展-------------------------------------------------------------

systemctl 是管制服务的主要工具, 它整合了chkconfig 与 service功能于一体。

systemctl is-enabled iptables.service
systemctl is-enabled servicename.service #查询服务是否开机启动
systemctl enable *.service #开机运行服务
systemctl disable *.service #取消开机运行
systemctl start *.service #启动服务
systemctl stop *.service #停止服务
systemctl restart *.service #重启服务
systemctl reload *.service #重新加载服务配置文件
systemctl status *.service #查询服务运行状态
systemctl --failed #显示启动失败的服务

注:*代表某个服务的名字,如http的服务名为httpd

============ 欢迎各位老板打赏~ ===========

本文版权归Bruce's Blog所有,转载引用请完整注明以下信息:
本文作者:Bruce
本文地址:CentOS 7将linux服务加入系统启动 systemd service | Bruce's Blog

发表评论

留言无头像?