#! /bin/bash
counter=0
utilization=`top -n 2 | fgrep "Cpu(s)" | tail -n 1 | awk '{printf "%s", $2}'`
echo $utilization
if [ `echo "$utilization > 90" | bc` -eq 1 ]; then
((counter++))
fi
echo $counter
sleep 30
if [ $counter -eq 1 ]; then
utilization=`top -n 2 | fgrep "Cpu(s)" | tail -n 1 | awk '{printf "%s", $2}'`
echo $utilization
if [ `echo "$utilization > 90" | bc` -eq 1 ]; then
kill -USR2 `cat /opt/php/php71/var/run/php-fpm.pid`
fi
fi
不同的版本,對應的檔案路徑會有些出入,以上僅供參考,請君靈活處理。
轉載本文,請註明出處、作者