Start ~ Start-Up Script As Process

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
chitownmafia
DD-WRT Novice


Joined: 29 Dec 2011
Posts: 16

PostPosted: Sat May 20, 2017 6:24    Post subject: Start ~ Start-Up Script As Process Reply with quote
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
Sponsor
chitownmafia
DD-WRT Novice


Joined: 29 Dec 2011
Posts: 16

PostPosted: Sat May 20, 2017 6:43    Post subject: I made some adjustments to the script.. Reply with quote
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 10000.00 ]; then reboot; else echo "sleeping 5" && sleep 5; fi done


~ NM After testing these adjustments.. the script is now working properly..
chitownmafia
DD-WRT Novice


Joined: 29 Dec 2011
Posts: 16

PostPosted: Sat May 20, 2017 7:12    Post subject: I tried to setup as "Cron Job" && Start-Up Reply with quote
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
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum