烤机启动程序.sh 700 B

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