add sh files

This commit is contained in:
root 2023-04-19 19:55:42 +08:00
parent bb734a37e6
commit e64dc5264a
2 changed files with 44 additions and 0 deletions

19
restart.sh Executable file
View File

@ -0,0 +1,19 @@
#! /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"
#cur_dateTime=$(date +%Y-%m-%d_%H-%m-%s)
f= "./log-"${cur_dateTime}".txt"
#mv log.txt $f
mv rxlog.txt "./rxlog-"${cur_dateTime}".txt"
nohup python3 -u ./server.py >>$f 2>&1 &
else
#echo ${cur_dateTime}" ---- ./server.py program is running"
fi
sleep 5
done

25
run_tt_server.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
kill_with_pid() {
pids=`ps aux | grep "./server.py" | grep -v grep | awk '{print $2}'`
if [ -n "$pids" ]; then
echo “service is running, pid is ${pids}""
echo "kill the service."
kill -9 $pids
else
echo "service is not running"
fi
}
kill_with_pid
echo "Now run new service."
#
cur_dateTime=$(date +%Y-%m-%d_%H-%M)
#cur_dateTime=$(date +%Y-%m-%d_%H-%m-%s)
echo ${cur_dateTime}
#mv log.txt "./log-"${cur_dateTime}".txt"
f="./log-"${cur_dateTime}".txt"
mv rxlog.txt "./rxlog-"${cur_dateTime}".txt"
nohup python3 -u ./server.py >>$f 2>&1 &
nohup ./restart.sh &
echo "Done."