Posted: Sat May 20, 2017 6:24 Post subject: Start ~ Start-Up Script As Process
Start ~ Start-Up Script As Process
Issue::
Currently the while loop will keep looping and not allow the router to boot as normal, As this script keeps a eye on the latency of the ping, from the router to the gateway... and if the latency is too high the router should reboot..
Script::
INTERVAL=5 && while sleep $INTERVAL;do
OUTPUT="$(ping 10.255.152.1 -c 5 > ping_time.txt && cat ping_time.txt | grep -e 'time=' | sed 's/.\{3\}$//' | sed 's/^..............................................//' > ms_stripped.txt && awk '{ sum += $1 } END { print sum }' ms_stripped.txt)" &&
if [ "$OUTPUT"-ge 1000.00 ]; then
reboot
else
echo "sleeping 5"
sleep 5
fi
done
Posted: Sat May 20, 2017 7:12 Post subject: I tried to setup as "Cron Job" && Start-Up
I tried to setup as "Cron Job" && Start-Up Script ~ No Go
I made a small adjustment to the script to write to the /tmp/root dir, just to make sure that the script was running, and after trying both "Start-Up Script" & "Cron Job", the output file is not showing in the "/tmp/root" dir..
Here is the updated script::
INTERVAL=5 && while sleep $INTERVAL;do OUTPUT="$(ping 10.255.152.1 -c 5 > ping_time.txt && cat ping_time.txt | grep -e 'time=' | sed 's/.\{3\}$//' | sed 's/^..............................................//' > ms_stripped.txt && awk '{ sum += $1 } END { print sum }' ms_stripped.txt)" && if [ "$OUTPUT"-ge 5000.00 ]; then reboot; else echo "sleeping 5" >> /tmp/root/Start_Up_Script.txt && sleep 5; fi done