add script

This commit is contained in:
LiuJR 2024-06-30 18:15:06 +08:00
parent 45acf0cca5
commit 38f36fd0ca
2 changed files with 38 additions and 6 deletions

View File

@ -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

31
start.sh Normal file
View File

@ -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