用Python编写daemon监控进程并自动恢复(附Shell版)(3)

#/bin/sh
while true;
do
  count=`ps -fe | grep "java" | grep "datanode" | grep -v "grep"`
  if [ "$?" != "0" ]; then
    /opt/modules/hadoop/hadoop-0.20.203.0/bin/hadoop-daemon.sh start datanode
  fi
  sleep 2
done

-----------------------------------

#/bin/sh
while true;
do
  count=`ps -fe | grep "java" | grep "tasktracker" | grep -v "grep"`
  if [ "$?" != "0" ]; then
    /opt/modules/hadoop/hadoop-0.20.203.0/bin/hadoop-daemon.sh start tasktracker
  fi
  sleep 2
done


其实作用是一样的,只是一个前台,一个后台。一个占用bash,一个占用python

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/psjjw.html