添加systemctl守护进程的自动任务

其他杂项27字数 562阅读1分52秒阅读模式

vim /etc/systemd/system/auto_check.service

[Unit]
Description=The python script used for release
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
ExecStart=/usr/bin/python3 /www/wwwroot/crontab.py
Restart=on-failure
[Install]
WantedBy=multi-user.target

启动该脚本并且开机运行

systemctl start auto_check
systemctl enable auto_check

 

启动该服务    sudo systemctl start auto_check

重启该服务    sudo systemctl restart auto_check

停止该服务    sudo systemctl stop auto_check

查看运行状态    sudo systemctl status auto_check

设置开机运行    sudo systemctl enable auto_check

查看日志    journalctl -xu auto_check

 
  • 本文由 asdfasd 发表于 2025-02-1710:35:08
  • 转载请务必保留本文链接:http://wp.fangfa.me/other-note/%e6%b7%bb%e5%8a%a0systemctl%e5%ae%88%e6%8a%a4%e8%bf%9b%e7%a8%8b%e7%9a%84%e8%87%aa%e5%8a%a8%e4%bb%bb%e5%8a%a1.html