1、服務(wù)文件
- ExecStart,改成自己腳本的路徑,比如程序啟動(dòng)腳本
- Restart,異常重啟
- RestartSec,異常后多少秒后重啟
- StartLimitInterval,異常后重試多少次,0 一直重試
[Unit]
Description=your_app
[Service]
Type=your_app
ExecStart=/root/your_app.sh
Restart=always
RestartSec=5
StartLimitInterval=0
[Install]
WantedBy=default.target
2. 配置
將上述文件命名為 your_app.serivce
,放入/etc/systemd/system
目錄下
比如,你的服務(wù)名稱叫 your_app
服務(wù)啟用
sudo systemctl enable your_app
服務(wù)啟動(dòng)
sudo systemctl start your_app
服務(wù)重新啟動(dòng)
sudo systemctl restart your_app
服務(wù)停止
sudo systemctl stop your_app
服務(wù)禁用
sudo systemctl disable your_app
服務(wù)配置更新文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-857133.html
sudo systemctl daemon-reload
服務(wù)狀態(tài)文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-857133.html
sudo systemctl status your_app
到了這里,關(guān)于【Ubuntu20.04】使用 systemd 進(jìn)行服務(wù)部署的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!