Linux创建脚本服务

创建脚本:

vi ***.sh
chmod a+x ***.sh

创建服务:

vi /etc/systemd/system/***.service
[Unit]
Description=demo

[Service]
ExecStart=/bin/bash /root/***.sh

[Install]
WantedBy=multi-user.target
#创建服务
systemctl enable nginx.service

#常用命令
systemctl start nginx.service    #启动nginx
systemctl stop nginx.service    #结束nginx
systemctl restart nginx.service    #重启nginx
原文地址:https://www.cnblogs.com/wintertone/p/15758609.html