What's new

Need a script that auto reboot if internet is down

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

I enabled "Enable JFFS custom scripts and configs" on Merlin/Admin/System page
I followed the steps on post 73 via Putty, line by line
Rebooted
Ran ./ChkWAN.sh noaction once nowait
Result =
Code:
ASUSWRT-Merlin RT-AX88U 386.3_2 Fri Aug  6 21:48:27 UTC 2021
admin@RT-AX88U-10C0:/tmp/home/root# ./ChkWAN.sh noaction once nowait
-sh: ./ChkWAN.sh: not found
admin@RT-AX88U-10C0:/tmp/home/root#

Do I need to change the path before following #73 on Merlin?
 
Sorry
Code:
cru a ChkWAN "*/5 * * * * /jffs/scripts/ChkWAN.sh wan quiet nowait"
Doesn't return anything

Post 79 says:
You can manually test the script with the default PING method, and the script will simply passively report the status, rather proactively restart the WAN or REBOOT

Code:
./ChkWAN.sh noaction once nowait

I'm just wondering how to ensure everything is working.
 
I'm using CHKWAN, and it's working great. I'm thinking most of the confusion on here is with permissions - people failing to set wan-start to 755 (chmod 755 wan-start). It should probably be added to the github instructions. Also, for the bulk of us, nano is the easiest editor to create wan-start, and it is very easy to install once you have a usb mounted and entware installed (a snap using amtm):
opkg install nano
 
Thank you for this script. I tried it yesterday as I have intermittent trouble with the dreaded 'Your ISP DHCP is not functioning' (or text to that effect).

While it did reboot the router, my USB drive with Diversion and a few other scripts, failed to mount. As a result, the WAN did seem up as I now had an IP address from my ISP and NO red LED on my AX88U, but I didn't have any Internet.

Is there a way to gracefully kill running apps etc before the reboot?
 
Thank you for this script. I tried it yesterday as I have intermittent trouble with the dreaded 'Your ISP DHCP is not functioning' (or text to that effect).

While it did reboot the router, my USB drive with Diversion and a few other scripts, failed to mount. As a result, the WAN did seem up as I now had an IP address from my ISP and NO red LED on my AX88U, but I didn't have any Internet.
ChkWAN initiates a SOFT boot using
Code:
service start_reboot
but it has been reported/observed many times that a HARD boot is more comprehensive and invariably (electronically) reliably more effective.

So, if you issue the above command manually several times, does the router exhibit consistent SOFT BOOT behaviour? (either 100% BOOT services success or 100% BOOT services failure)
Is there a way to gracefully kill running apps etc before the reboot?
Possibly

i.e. if you believe you need an ordered shutdown to mange your custom apps/services then you should use an appropriate event script to implement the necessary shutdown actions:

e.g

Code:
service-event

service-event-end 

services-stop
 
Thank you Martineau for the script and hope you can help. ChkWan script was monitoring fine when using wan-start and a older firmware. I recently upgraded the firmware to 386.5 and followed the https://github.com/MartineauUK/Chk-WAN instructions to use wan-event. Manually checking the script using "./ChkWAN.sh noaction once nowait" it runs fine. Whenever I reboot the router, ChkWAN doesn't automatically start like before. I see the following for wan-event in the logs.

Mar 17 13:33:19 custom_script: Running /jffs/scripts/wan-event (args: 0 stopped)
Mar 17 13:33:19 custom_script: Running /jffs/scripts/wan-event (args: 0 stopped)
Mar 17 13:33:19 custom_script: Running /jffs/scripts/wan-event (args: 0 init)
Mar 17 13:33:19 custom_script: Running /jffs/scripts/wan-event (args: 0 connecting)
Mar 17 13:33:19 custom_script: Running /jffs/scripts/wan-event (args: 0 disconnected)
 
I would just like to thank everyone involved in writing this script.

I intermittently loose Internet connection on my Virgin Media (UK) 350/30 service. I don't think it is an actual cable MODEM-ISP issue, as I must reboot my AX88U router (not the actual cable modem), to get service back. When I check the CM logs after an outage, I cannot see any potential problems entered.

The outage happens randomly, could be a day or week or two apart, the randomness of it adds to the frustration.

Now that I have the ChkWAN script running and checking WAN connectivity every 5 minutes, it's no longer a problem. My Ring alarm sends me a message stating it is on mobile backup, and usually withing 6-7 minutes I get another saying service is restored. When I check my routers DCL log via AMTM I see that the router rebooted itself when ChkWAN detected Internet failure.

Great stuff.
 
Thank you Martineau for the script and hope you can help. ChkWan script was monitoring fine when using wan-start and a older firmware. I recently upgraded the firmware to 386.5 and followed the https://github.com/MartineauUK/Chk-WAN instructions to use wan-event. Manually checking the script using "./ChkWAN.sh noaction once nowait" it runs fine. Whenever I reboot the router, ChkWAN doesn't automatically start like before. I see the following for wan-event in the logs.

Mar 17 13:33:19 custom_script: Running /jffs/scripts/wan-event (args: 0 stopped)
Mar 17 13:33:19 custom_script: Running /jffs/scripts/wan-event (args: 0 stopped)
Mar 17 13:33:19 custom_script: Running /jffs/scripts/wan-event (args: 0 init)
Mar 17 13:33:19 custom_script: Running /jffs/scripts/wan-event (args: 0 connecting)
Mar 17 13:33:19 custom_script: Running /jffs/scripts/wan-event (args: 0 disconnected)
In the instructions posted by @Carme the suggestion was to use the following to load the command in nvram to force the script to restart at next reboot: nvram set script_usbmount="/jffs/ChkWAN.sh"
 
@YellowTail This post came to the top of the list. I was setting up ChkWAN and it also didn't start up on the wan-event trigger. I figured out the issue. On the GitHub page, the script that goes in wan-event has a typo...the last line in the if block is:

Code:
sh /jffs/scripts/CHKWAN.sh &

when it should be:

Code:
sh /jffs/scripts/ChkWAN.sh &

the case of the file name matters. After I changed that, mine worked fine. I also changed the script to check every 2 minutes and to restart the wan only.
 
@YellowTail This post came to the top of the list. I was setting up ChkWAN and it also didn't start up on the wan-event trigger. I figured out the issue. On the GitHub page, the script that goes in wan-event has a typo...the last line in the if block is:

Code:
sh /jffs/scripts/CHKWAN.sh &

when it should be:

Code:
sh /jffs/scripts/ChkWAN.sh &

the case of the file name matters. After I changed that, mine worked fine. I also changed the script to check every 2 minutes and to restart the wan only.
Thanks for the GitHub Readme documentation bug report - fixed.
 
can you enable scripts on a lyra ai mesh node? I have one in an outbuilding that requires a reboot to reconnect sometimes.
 
If I were to move an AC3100 (merlin aimesh) there instead could I run it on that? I know I can run scripts, but would a mesh client detect the same WAN down as the main router?
 
Well, it seems to be working, will need to see next time it would go offline.
Oct 7 16:35:01 (ChkWAN.sh): 19116 v1.17 Monitoring WAN connection using 4 target PING hosts (192.168.1.1 192.168.1.1 9.9.9.9 1.1.1.1) (Tries=3)
Oct 7 16:35:01 (ChkWAN.sh): 19116 Private LAN 192.168.1.1 will be skipped for WAN PING check!
Oct 7 16:35:01 (ChkWAN.sh): 19116 Private LAN 192.168.1.1 will be skipped for WAN PING check!
 
FYI, I changed the script to check every 2 minutes to make it re-initiate the WAN connection in a reasonable amount of time. When the WAN goes down, by the time the script checks each IP address listed and then retries them the specified number of times in the script, it can be many minutes. I think mine with 3 IP addresses and 3 tries and then restarting the WAN only (i.e. not rebooting the router), it can take from 5 to 15 minutes...can't remember for sure.

Just saying to keep an eye on it if/when it happens...first see how long it takes to restart the connection and then adjust the parameters as needed. I'd say you don't want to ping too frequently.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top