Lets go:
We need have two files:
Code: Select all
touch increaseup.sh
touch totalup.sh- in to increaseup.sh copy:
Code: Select all
#!/bin/bash
TOTAL_UP_FILE=/root/uptime
UPTIME=`cat /proc/uptime | awk -F"." '{print $1}'`
if [ -s $TOTAL_UP_FILE ]; then
SAVED_UPTIME=`cat $TOTAL_UP_FILE`
fi
TOTAL_UPTIME=$[$SAVED_UPTIME+$UPTIME]
echo $TOTAL_UPTIME > $TOTAL_UP_FILE
echo " * ...increasing total uptime..."
exit 0
Code: Select all
#!/bin/bash
TOTAL_UP_FILE=/root/uptime
if [ -s $TOTAL_UP_FILE ]; then
UPTIME=`cat $TOTAL_UP_FILE`
fi
DAYS=$[$UPTIME/86400]
UPT=$[$UPTIME-$DAYS*86400]
UPTIME=$UPT
HOURS=$[$UPTIME/3600]
UPT=$[UPTIME-$HOURS*3600]
UPTIME=$UPT
MINS=$[$UPTIME/60]
UPT=$[$UPTIME-$MINS*60]
SECS=$UPT
echo "*** Total uptime counter start: xx/xx/xx"
echo "*** Total uptime: $DAYS d, $HOURS h, $MINS m, $SECS s ($DAYS d, $HOURS:$MINS:$SECS)"
exit 0
Code: Select all
touch /root/uptime Now you have to add the:
Code: Select all
/path/to/inreaseup.shNow after reboot or shutdown script will be sum up your uptime. You may check this using totalup.sh:
Code: Select all
/path/to/totaupl.sh G.


