diff --git a/server_login_detection.service b/server_login_detection.service index e258cdc..4020074 100644 --- a/server_login_detection.service +++ b/server_login_detection.service @@ -1,11 +1,12 @@ -# 添加以下内容到服务文件 [Unit] -Description=My Python App - +Description=server_login_detection + [Service] Type=simple -ExecStart=python3 /path/to/your/run.py - +ExecStart=/start.sh +Restart=always +RestartSec=5 +StartLimitInterval=0 + [Install] WantedBy=multi-user.target - diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..b71de02 --- /dev/null +++ b/start.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +echo "程序开始运行!" + +if ! pgrep -f "run.py" > /dev/null +then + python3 run.py +fi + +echo *********start python_scripts success******* + +sleep 30 + + + +# pip3 install -r requirements.txt + +# sudo yum install inotify-tools +# sudo apt install inotify-tools + +# python3 ./run.py + +# sudo cp server_login_detection.service /etc/systemd/system/ +# sudo systemctl daemon-reload + +# sudo systemctl start server_login_detection.service + +# sudo systemctl status server_login_detection.service + +# sudo systemctl stop server_login_detection.service +