#!/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} # cd ~/tt-tcp #mv log.txt "./log-"${cur_dateTime}".txt" # f="./log-"${cur_dateTime}".txt" mv rxlog.txt "rxlog/rxlog-"${cur_dateTime}".txt" nohup python3 -u ./server.py & #nohup ./restart.sh & nohup ./restart.sh >> reboot.log & echo "Done."