You are not logged in.
The "What's Your Uptime?" thread inspired me to share this script. It keeps track of my uptime every day, deleting yesterday's entry unless today's is smaller. That way I get a log of longest uptimes.
#!/bin/sh
# This should be called from cron once per day to log uptime
# Log format: 'MM/DD/YY up XX days'
LOG=$HOME/text/uptimelog.txt
DAYS=0
uptime|grep -q days && DAYS="$(uptime|sed 's/.*up \([0-9]*\) days.*/\1/')"
# Delete the last line from the log unless we've rebooted
if [ -s $LOG ]; then
LAST="$(tail -n1 $LOG | sed 's/^.*up *\([0-9]*\) *days.*$/\1/')"
if [ -n "$LAST" ] && [[ $DAYS -ge $LAST ]]; then
sed -i '$ d' $LOG
fi
fi
# Log the current uptime
printf "$(date +%D) up %2d days\n" $DAYS >> $LOG
I save this as ~/bin/cron_uptime and run it with this crontab entry:
4 4 * * * $HOME/bin/cron_uptime
It's also here.
In the past three years, I've recorded one 50-day uptime, two in the 40s and three in the 30s. That was my Fedora system. I just now set it up on my Arch system. These numbers are actually artificially low because I feel compelled to reboot every time a kernel is released--which seems to happen fairly often.
Offline