#! /bin/bash
N=20
while :;
do
load=`uptime |awk '{print $10}' |cut -d'.' -f 1`
if [ $load -gt $N ] ; then
uptime |awk '{print $1,$8,$9,$10,$11,$12}' >>/root/anaload/`date +%m%d`_anaload.txt
vmstat 1 600 >>/root/anaload/`date +%m%d`_anaload.txt
echo " " >>/root/anaload/`date +%m%d`_anaload.txt
fi
sleep 10
done
N=20
while :;
do
load=`uptime |awk '{print $10}' |cut -d'.' -f 1`
if [ $load -gt $N ] ; then
uptime |awk '{print $1,$8,$9,$10,$11,$12}' >>/root/anaload/`date +%m%d`_anaload.txt
vmstat 1 600 >>/root/anaload/`date +%m%d`_anaload.txt
echo " " >>/root/anaload/`date +%m%d`_anaload.txt
fi
sleep 10
done
0
#! /bin/bash
N=‘grep -c "model name" /proc/cpuinfo`
while :;
do
load=`uptime |awk '{print $NF}' |cut -d'.' -f 1`
if [ $load -gt $N ] ; then
uptime |awk '{print $1,$8,$9,$10,$11,$12}' >>/root/anaload/`date +%m%d`_anaload.txt
vmstat 1 600 >>/root/anaload/`date +%m%d`_anaload.txt
echo " " >>/root/anaload/`date +%m%d`_anaload.txt
fi
sleep 10
done
N=‘grep -c "model name" /proc/cpuinfo`
while :;
do
load=`uptime |awk '{print $NF}' |cut -d'.' -f 1`
if [ $load -gt $N ] ; then
uptime |awk '{print $1,$8,$9,$10,$11,$12}' >>/root/anaload/`date +%m%d`_anaload.txt
vmstat 1 600 >>/root/anaload/`date +%m%d`_anaload.txt
echo " " >>/root/anaload/`date +%m%d`_anaload.txt
fi
sleep 10
done
0
$N 没有值 if判断就会一直是false
SHMILY 发表于 2015-1-6 10:15
#! /bin/bash
N=‘grep -c "model name" /proc/cpuinfo`
$N 没有值 if判断就会一直是false
编辑回复