其他分享
首页 > 其他分享> > centeros 8 配置 systemctl

centeros 8 配置 systemctl

作者:互联网

systemctl

  1. 新建脚本,例如,/tmp/mytest.sh,设置权限chmod +x /tmp/mytest.sh

  2. 进入目录/usr/lib/systemd/system,新建服务,例如mytest.service,编辑为如下形式:

    highlighter- code-theme-dark ini
    [Unit]
    Description=mytest for auto start
    Wants=network-online.target
    
    [Service]
    User=root
    Type=forking
    ExecStart=/usr/bin/bash /tmp/mytest.sh start
    ExecStop=/usr/bin/bash /tmp/mytest.sh stop
    
    [Install]
    WantedBy=multi-user.target
  3. 重新加载systemd配置systemctl daemon-reload

  4. 添加开机自启动systemctl enable mytest.service

  5. reboot重启验证

标签:tmp,systemd,mytest,centeros,配置,sh,systemctl,usr
来源: https://www.cnblogs.com/dbqjava/p/16558326.html