Reboot/Up/Down times : Script to show

Discussion in 'Other Firmware Projects' started by mdes, Aug 16, 2004.

  1. mdes

    mdes Guest

    Here is a shell script to show the reboot, up and down date/time (adapted from gzav's idea @ http://forpage.com/forum/viewtopic.php?p=52288#52288):
    Code:
    sleep 20 
    date +"reboot: %Y/%m/%d %X" >> /var/log/free.log 
    echo "#!/bin/sh" >/var/log/test 
    echo "cp /var/log/? /var/log/?.last" >>/var/log/test 
    echo "ping -c 1 \`nvram get wan_gateway\` | grep received | cut -d\" \" -f4 > /var/log/?" >>/var/log/test 
    echo "if grep -q 1 /var/log/?" >>/var/log/test 
    echo "then" >>/var/log/test 
    echo " if grep -q 0 /var/log/?.last" >>/var/log/test 
    echo " then" >>/var/log/test 
    echo " date +"\"up____: %Y/%m/%d %X \`nvram get wan_ipaddr\`\"" >> /var/log/free.log" >>/var/log/test 
    echo " fi" >>/var/log/test 
    echo "else" >>/var/log/test 
    echo " if grep -q 1 /var/log/?.last" >>/var/log/test 
    echo " then" >>/var/log/test 
    echo " date +"\"down__: %Y/%m/%d %X\"" >> /var/log/free.log" >>/var/log/test 
    echo " fi" >>/var/log/test 
    echo "fi" >>/var/log/test 
    echo 0 > /var/log/? 
    chmod 700 /var/log/test 
    echo "* * * * * root /var/log/test" >> /tmp/crontab
    The resulting file could be seen by:
    Code:
    cat /var/log/free.log
    Code:
    reboot: 2004/08/15 09:30:07
    up____: 2004/08/15 09:32:01 80.119.35.138
    down__: 2004/08/15 09:36:02
    reboot: 2004/08/15 09:36:31
    up____: 2004/08/15 09:37:00 80.119.35.248
    down__: 2004/08/15 10:37:01
    down__: 2004/08/15 10:37:22
    up____: 2004/08/15 10:37:24 80.119.35.248
    down__: 2004/08/16 03:36:45
    up____: 2004/08/16 03:36:57 80.119.35.248
     
  2. jdepew

    jdepew Administrator Staff Member Member

    Very neat! What else have you got up your sleeve?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice