秦F103机巢代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
760B

  1. #!/bin/bash
  2. log_file="restart.log"
  3. function time_stamp()
  4. {
  5. echo $(date "+%Y-%m-%d %H:%M:%s")
  6. }
  7. function run()
  8. {
  9. ./DroneNest 1>/dev/null 2>&1 &
  10. }
  11. function check_alive()
  12. {
  13. num=$(ps -ef |grep DroneNest |grep -v grep |wc -l)
  14. if [ $num -lt 1 ];
  15. then
  16. echo "$(time_stamp) DroneNest not exsit,start it ..." >> $log_file
  17. run
  18. fi
  19. }
  20. function del_expired_log()
  21. {
  22. find /root/TH-DNest/logs -mtime +15 -name "*.*" -exec rm -rf {} \;
  23. }
  24. ######################### MAIN ###############################
  25. basepath=$(cd `dirname $0`; pwd)
  26. cd $basepath
  27. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/TH-DNest/lib
  28. while true
  29. do
  30. check_alive
  31. del_expired_log
  32. sleep 10
  33. done