diff --git a/restart.sh b/restart.sh new file mode 100755 index 0000000..83c84a1 --- /dev/null +++ b/restart.sh @@ -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 diff --git a/run_tt_server.sh b/run_tt_server.sh new file mode 100755 index 0000000..1747f67 --- /dev/null +++ b/run_tt_server.sh @@ -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."