tt-server/restart.sh

20 lines
545 B
Bash
Executable File

#! /bin/sh
while true; do
monitor=$(ps -ef | grep "./server.py" | grep -v grep | wc -l)
cur_dateTime=$(date +%Y-%m-%d_%H-%M-%s)
if [ $monitor -eq 0 ]; then
echo $cur_dateTime" --- ./server.py program is not running, restart now"
cd ~/tt/tt-tcp
#if= "./log-"$cur_dateTime".txt"
f="./log-"${cur_dateTime}".txt"
mv "./rxlog.txt" "./rxlog-"${cur_dateTime}".txt"
#cd /root/tt/tt-tcp
#mv rxlog.txt "./rxlog-"$cur_dateTime".txt"
nohup python3 -u ./server.py >>$f 2>&1 &
fi
sleep 5
done