1. service文件
vim /etc/systemd/system/demo.service
[Unit]
# 描述
Description=Demo Service
[Service]
# 以启动子进程方式运行
Type=forking
# 执行路径
WorkingDirectory=/root/demo/
# 通过启动脚本启动(为了继承系统变量)
ExecStart=/etc/demo.sh
# 日志文件
StandardOutput=file:/var/log/demo.log
StandardError=file:/var/log/demo.log
# 永远重启
Restart=always
# 异常退出重启时间
RestartSec=60s
# 调度优先级 -20最高,19最低
Nice=19
[Install]
WantedBy=multi-user.target