背景说明
- 截至 2020.11.17,SystemD 早已已经战胜 upstart 成为 SystemV 的接任者。CentOS 7/8、Ubuntu 18.04/20.04 LTS 默认配置都是 SystemD。
测试环境
- CentOS 7
测试步骤
- 编写
/root/tmp/qbit_startup.sh 文件
1 | date > /root/tmp/qbit_starup.txt |
- 编写
/usr/lib/systemd/system/qbit_starup.service 文件
1 2 3 4 5 6 7 8 9 10 11 | [Unit] Description=自定义启动脚本 ConditionPathExists=/root/tmp/qbit_startup.sh After=network.target [Service] Type=forking ExecStart=/usr/bin/bash /root/tmp/qbit_startup.sh [Install] WantedBy=multi-user.target |
- 刷新配置
1 | sudo systemctl daemon-reload |
- 启动测试
1 | sudo systemctl start qbit_startup |
- 设置开机启动
1 | sudo systemctl enable qbit_startup |
- 重启测试
本文出自 qbit snap