1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

reboot script

Discussion in 'Tomato Firmware' started by Low-WRT, Jan 4, 2013.

  1. Low-WRT

    Low-WRT LI Guru Member


    I have a Asus RT-N16 running tomatousb as a wireless ethernet bridge.
    Everyday or so, it messes up and is not connected to the ap. I usually just reboot it and it works.
    I searched and found this script:

    /bin/ping -c 1 www.google.com > /dev/null; if [[ $? != 0 ]]; then /sbin/reboot; fi
    I put this in the custom scheduler and set it to run every 30 min.
    Is this the best way to do this?

  2. fubdap

    fubdap Addicted to LI Member

    Tomato already has reboot built-in. Go to Administration, go to scheduler and you will see the image below. Pick the day and time and save.

  3. Goggy

    Goggy Network Guru Member

  4. Elfew

    Elfew Addicted to LI Member

    So which script should I use for autoreconnect when the connection to the main router is off?
  5. Monk E. Boy

    Monk E. Boy Network Guru Member

    Oh god. There used to be an awesome script in here that got lost when the board was wiped and restored from backup. :( Sorry, I wish I had saved it.
  6. kthaddock

    kthaddock Network Guru Member

    You mean this script:
    if [ "$1" != "" ]; then
    if [ "$2" != "" ]; then
    ploss=`ping -q -w$pingtime $trip | grep -o "[0-9]*%" | tr -d %` > /dev/null 2>&1
    if [ "$ploss" -gt "$maxPloss" ]; then
          logger No response from $trip - rebooting...
    exit 0

    Attached Files:

    • p.txt
      File size:
      365 bytes
  7. Elfew

    Elfew Addicted to LI Member

    So this script does what I need? Reconnect/reboot router everytime when the internet connection is offline? Thank you..

    and one more thing - it reboots again and again until the internet connection will be ON? Thank you again
  8. zorkmta

    zorkmta LI Guru Member

    where should put this scritps? On Admintration- Scripts- (INIT or Shutdown or firewall or WAN UP)?'?
  9. Monk E. Boy

    Monk E. Boy Network Guru Member

    I believe you would want to create a shell script on a writable folder (JFFS, or a CIFS share, or a USB device), then call that script under Custom 1 on a fixed schedule.

    I sort of remember someone adding some nice logic to determine if the WAN interface came up, then it would run 24/7 in the background once the WAN came up, so you could put it in either Init or Firewall.

    The posted script just runs once and reboots if the ping fails or is too high, which is great and perfectly useful, its just not as awesome as I remember.

Share This Page