该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
问题:我把脚本放到 /etc/profile.d/目录下,运行脚本,系统就不断重启了,而我设置的重启次数是2次,超过两次后还是在不断重启,CN在不断增加,但是error.txt日志却没在增加,这是怎么回事啊!
#!/bin/bash
##### 本脚本用于测试Microsemi设备是否启动 ##############
##### 检测到两个设备启动了就重启系统 ################
##### 设重启的次数可设置,并保存打印信息 ##########
if [ -d /root/Desktop/errlog.txt ];then :
else
touch /root/Desktop/errlog.txt
fi
if [ -d /root/Desktop/cn ];then :
else
touch /root/Desktop/cn
fi
if [ -d /root/Desktop/RebootLog.txt ];then :
else
touch /root/Desktop/RebootLog.txt
fi
CN=`cat /root/Desktop/cn`
CN=$(($CN+1))
echo $CN > /root/Desktop/cn
num=` lspci | grep -i Microsemi | wc -l `
while [ $CN -lt 2 ]
do
if [ $num == 2 ] &>/dev/null;then
echo "find two Microsemi devices, system reboot at $(date)" >>/root/Desktop/RebootLog.txt
/sbin/reboot
else
echo "error, Microsemi devices less then two, reboot time at : $(date)" >>/root/Desktop/errlog.txt
/sbin/reboot
fi
done
exit 0