EdgeGateway_FSU/EdgeGateway_FSU_App/bsh/loopsh.sh

84 lines
2.2 KiB
Bash
Raw Permalink Normal View History

2024-03-15 17:25:04 +08:00
#!/bin/sh
#增加一个输入判断,防止一直运行无法跳出循环 kooloo add 2024022201
echo "Press any key to continue... except e or E... ?\n"
echo "Press any key to continue... except e or E...">> /home/EdgeGateway_FSU_App/log/Devicestartup.log
Tempi=1
while [ $Tempi -le 2 ]
do
echo $Tempi
let Tempi++ #注意这里如果不改变$i的值会变成死循环
#read Tempstr
read -t 8 Tempstr #8s 内输入 kooloo add 2024022301
echo "Tempstr的值为: $Tempstr ?\n"
if [[ $Tempstr == e ]];then
echo "e break!"
exit
elif [[ $Tempstr == E ]];then
echo "E break!"
exit
fi
#sleep 1
# Tempi=$[$Tempi+1] //两种写法
done
echo "最后Tempi的值为: $Tempi ?\n"
echo "Continuing... ?\n"
#时间校准进程
date >>/home/EdgeGateway_FSU_App/log/Devicestartup.log
while [ 1 -eq 1 ] #写一个永远为真的表达式1等于1这个条件永远为真所以这个脚本会一直循环下去
do
PIDSTest=`ps -ef | awk '{print}'`
echo $PIDSTest >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
echo "当前所有PID值,$PIDSTest "
PIDS=`ps -ef |grep MainProcessApp |grep -v grep | awk '{print $1}'`
echo $PIDS >> /home/EdgeGateway_FSU_App/log/Devicestartup.log
if [ "$PIDS" != "" ]; then
echo "MainProcessApp is runing!"
echo "MainProcessApp is runing!">> /home/EdgeGateway_FSU_App/log/Devicestartup.log
else #
echo "MainProcessApp is not runing!"
echo "MainProcessApp is not runing!">> /home/EdgeGateway_FSU_App/log/Devicestartup.log
#运行进程
fi
#判断log文件大小 如果超过一定值 则将其清空
file_size=$(stat -c %s "/home/EdgeGateway_FSU_App/log/Devicestartup.log")
if [ $file_size -gt 10000000 ]; then
echo "文件太大,需要清空,$file_size "
" " >/home/EdgeGateway_FSU_App/log/Devicestartup.log
else
echo "文件大小不为0"
fi
ping www.baidu.com -c 4
Tempj=1
while [ $Tempj -le 5 ]
do
let Tempj++ #注意这里如果不改变$i的值会变成死循环
sleep 1
echo 0 > /sys/class/leds/Dbg-led0/brightness
#ping baidu.com
sleep 1
echo 1 > /sys/class/leds/Dbg-led0/brightness
#ping baidu.com
done
done
echo "end"
#test use kooloo add 202312
#cd /home/EdgeGateway_FSU_App/App