code

  1. #!/bin/bash
  2. EMAIL='zhangcunchao@521php.com'
  3. start()
  4. {
  5. c=`ps w -C php|grep $1|wc -l`
  6. if [ $c -lt 1 ]
  7. then
  8. if [ -f "$1" ];then
  9. nohup /usr/local/php/bin/php $1 > /dev/null 2>&1 &
  10. else
  11. `echo 'no such file '$1 | mail -s 'process check error' $EMAIL`
  12. fi
  13. fi
  14. }
  15. BASE_PATH=`dirname $0`"/"
  16. cd $BASE_PATH
  17. start md_socket.php

可以监控多个进程

  1. BASE_PATH=`dirname $0`"/"
  2. cd $BASE_PATH

这个做到cd到脚本所在目录