码迷,mamicode.com
首页 > 系统相关 > 详细

shell检查网络出现异常、僵尸进程、内存过低后,自动重启

时间:2015-05-29 06:12:24      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:

#!/bin/bash
 while :
 do
     neterror=$(/bin/netstat -a | grep -cw  "CLOSE_WAIT")
     echo "get tcp netstate ‘LISTEN‘ number cuccessful!"
     echo "neterror"$neterror

     if [ $neterror -gt "10" ]; then
         echo "too much net error,system will reboot now!"
         sleep 2
         /sbin/reboot -f
     fi
         
         freememory=$(free -m | grep Mem | awk ‘{print $4}‘)
         echo "freesize:"$freememory

     if [ $freememory -lt "100" ]; then
         echo "the free memory size is less then 100M,system will reboot now!"
         sleep 2
         /sbin/reboot -f
     fi

     corpsprocess=$(ps -ef | awk ‘{print $3$4}‘ | grep -c "Z")
         echo "corpsprocess:"$corpsprocess
     if [ $corpsprocess -gt "0" ]; then
                echo "system had corps process,system will reboot now!"
                sleep 2
                /sbin/reboot -f
        fi
     
     sleep 2
 done

 

shell检查网络出现异常、僵尸进程、内存过低后,自动重启

标签:

原文地址:http://www.cnblogs.com/aibo/p/4537513.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!