服务

systemctl

服务相关
  • 注册服务
    • chkconfig --add test
    • 直接启动即可
  • 删除服务
    • chkconfig --del xxx
    • 停掉应用,并删除对应的配置文件
  • 启动服务
    • systemctl start httpd.service
    • service httpd start
  • 停止服务
    • systemctl stop httpd.service
    • service httpd stop
  • 重启服务
    • systemctl restart httpd.service
    • service httpd.service restart
  • 查看服务状态
    • service httpd status
    • systemctl status httpd.service
  • 使服务自启动
    • chkconfig --level 3 httpd on
    • systemctl enable httpd.service
  • 使服务不自启动
    • chkconfig --level 3 httpd off
    • systemctl diable httpd.service
  • 重新加载服务
    • systemctl reload ****.service
    • systemctl daemon-reload
服务脚本
  • unit 在/etc/systemd/system中添加unit脚本,取名为*.service
[Unit]
De ion=shadowsocks client
After=network.target
[Service]
ExecStart=/usr/local/bin/sslocal -c /etc/shadowsocks.json -- 这里好像要全路径的命令
[Install]
WantedBy=multi-user.target
收藏 打印