首頁 繪圖設計 工作閒聊 比賽活動 美術討論 標籤 圖片
Shell Script to Monitor process which stalled (cpu 100%)
Type(Type) 2013/2/26 14:54

Shell Script to Monitor process which stalled (cpu 100%)



Script: Use CutyCapt as an example


代碼:

#
# read last cutycapt pid
#
thisfile=/tmp/.cutycaptcheck

a=0
if [ -f "$thisfile" ]; then
        a=`head $thisfile | cut -b1-5`
fi

#
# record Capt into .cutycapcheck again
#
top -b -n 1 | grep Cuty > $thisfile

#
# read current pid
#
b=`head $thisfile | cut -b1-5`

#echo "a == $a"
#echo "b == $b"

if [ x"$a" = "x" ]; then
        logger "CutyCaptCheck: Do nothing (No A)"
        exit
fi

if [ x"$b" = "x" ]; then
        logger "CutyCaptCheck: Do nothing (No B)"
        exit
fi

if [ "$a" -eq "$b" ]; then
  logger "CutyCaptCheck: KILL pid = $a"
  kill -9 $a
else
        logger "CutyCaptCheck: Do nothing (A != B)"
fi



Then, modify the /etc/crontab if you it to run more frequently


e.g. Use "kill-CutyCapt" as an example
check if any CutyCapty stalled every 3 mins


代碼:

*/3     *       *       *       *       root    /usr/sbin/killcuty




_


(1,853 views)
[更多討論] 討論區 Windows, Linux, Perl, PHP, C/C++, Driver, Web 理論、應用、硬體、軟體




"Shell Script to Monitor process which stalled (cpu 100%)" 傳統頁面(電腦版)

首頁 繪圖設計 工作閒聊 比賽活動 美術討論 標籤 圖片
傳統桌面版 [ 登入/註冊 ]
© Vovo2000.com Mobile Version 小哈手機版 2018