centeros 8 配置 systemctl
作者:互联网
systemctl
-
新建脚本,例如,
/tmp/mytest.sh
,设置权限chmod +x /tmp/mytest.sh
-
进入目录
highlighter- code-theme-dark ini/usr/lib/systemd/system
,新建服务,例如mytest.service
,编辑为如下形式:[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
-
重新加载systemd配置
systemctl daemon-reload
-
添加开机自启动
systemctl enable mytest.service
-
reboot重启验证
标签:tmp,systemd,mytest,centeros,配置,sh,systemctl,usr 来源: https://www.cnblogs.com/dbqjava/p/16558326.html