26 lines
623 B
Bash
26 lines
623 B
Bash
|
#!/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."
|