add script
This commit is contained in:
parent
45acf0cca5
commit
38f36fd0ca
@ -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
31
start.sh
Normal 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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user