123456789101112131415161718192021222324252627282930 |
- #!/bin/bash
- # 获取当前时间
- hour=`date +%H`
- minute=`date +%M`
- # 获取进程数量,一个图像处理进程,一个前端交互进程
- process_sonar=`ps -ef | grep "test_tcp.py" | grep -v grep | wc -l`
- # sonar 进程
- if [[ $process_sonar -eq 0 ]]; then
- cd /home/sencott/sonar/sonar_control
- nohup /home/sencott/anaconda3/envs/sonar/bin/python test_tcp.py
- fi
- if [[ $process_sonar -ne 7 ]]; then
- # 查找 PID 并 kill 进程
- pid=`ps -ef | grep "test_tcp.py" | grep -v grep | awk '{print $2}'`
- if [[ ! -z $pid ]]; then
- echo "kill process $pid"
- kill -9 $pid
- fi
- cd /home/sencott/sonar/sonar_control
- nohup /home/sencott/anaconda3/envs/sonar/bin/python test_tcp.py
- fi
|