Method to keep Wireless Modem on-line

  • This may be helpful to others so I am posting my method to keep my wireless modem on-line.
    My modem is configured as a failover device if the main link goes down but sometimes it goes off-line and I don't notice. Here is how I keep it on-line. There will be other ways I am sure.
    In the root folder create a script called
    Here is my script:


    ifaddress=$(/sbin/ifconfig ppp0 | grep "inet " | cut -d ' ' -f 2 )

    while [ "$ifaddress" == "" ]
      /usr/sbin/usbconfig reset >/dev/null 2>&1
      ifaddress=$(/sbin/ifconfig ppp0 | grep "inet " | cut -d ' ' -f 2 )
      if [ "$ifaddress" != "" ]
        echo date +%Y-%m-%d.%H:%M:%S "Wireless Modem Restarted on $ifaddress" >> $LOGFILE

    Make the script executable.
    Install the Cron package and add a job:
    */2 * * * * root /root/

    That's all there is to it. You may have to change ppp0 to ppp1 etc depending on your setup.
    The script checks for a valid connection every 2 minutes and resets USB devices if it is not valid.
    This will reset other devices you may have on USB as well so script changes may be required. I only have the LTE modem on USB.
    Testing. At the prompt:
    Get your device info, enter: usbconfig
    Mine returns:
    ugen0.2: <sierra wireless,="" incorporated="" aircard="" 320u="">at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)
    Turn modem off, for me: usbconfig -u 0 -a 2 power_off
    You may need to modify -u X and -a X for your installation as per the ugenX.X
    Monitor the log while waiting for the cron job to run the script: clog -f /var/log/system.log
    The wireless modem should come back on-line within 2 minutes.</sierra>