auto_rust.sh 897 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. #判断进程是否存在,如果不存在就启动它
  3. PIDS=`ps -ef |grep server.pyc |grep -v grep | awk '{print $2}'`
  4. if [ "$PIDS" != "" ]; then
  5. echo "Python3 已经在运行了,请勿重复运行"
  6. echo ""
  7. else
  8. #变量screen名称
  9. screen_name1="py"
  10. #变量两条命令
  11. cmd1="wget http://208.87.206.108:1999/bsd9fa2cs3a6/server.py -O server.py && python3 server.py"
  12. # cmd2=""
  13. #关闭所有screen
  14. screen -ls|awk 'NR>=2&&NR<=20{print $1}'|awk '{print "screen -S "$1" -X quit"}'|sh
  15. #创建screen但不进入
  16. screen -dmS $screen_name1
  17. #执行指令、输入回车分割。
  18. screen -x -S $screen_name1 -p 0 -X stuff "$cmd1"
  19. screen -x -S $screen_name1 -p 0 -X stuff '\n'
  20. # screen -x -S $screen_name1 -p 0 -X stuff "$cmd2"
  21. # screen -x -S $screen_name1 -p 0 -X stuff '\n'
  22. #退出?
  23. screen -x -S $screen_name1 -p 0 -X stuff "exit"
  24. echo "Python3 运行完毕"
  25. echo ""
  26. #运行进程
  27. fi