There are entries in the /var/log/user.log Showing when the device sleeps and wakes up. create a file called sleep.awk of the following code.
awk ’
NR==1 { a=substr($1,6,2); b=substr($1,9,2); c=substr($1,12,8) }
{if ($7 ~ /after/){
hh1=int($8/3600)
mm1=int(($8%3600)/60)
ss1=($8%3600)%60
Total = Total + $8
printf “%2s %2s %8s %8s %5d %2d:%02d:%02d\n”,substr($1,6,2),substr($1,9,2) ,substr($11,0,9),substr($
1,12,8),$8 ,hh1,mm1,ss1}}
END {
hh1=int(Total/3600)
mm1=mm1=int(($8%3600)/60)
ss1=($8%3600)%60
printf “Total Sleep Time: %2d:%02d:%02d\n” ,hh1,mm1,ss1
start= a “/” b “/2015 " c
end= substr($1,6,2) “/” substr($1,9,2) “/2015 " substr($1,12,8)
$1=start
#print start " " end
cmd=“date --date="”$1"" +%s”
#print cmd
cmd|getline st
printf “Start %s\n” ,st
$1=end
cmd=“date --date="”$1"" +%s”
cmd|getline end
#print cmd
printf “End %s\n” ,end
Total=end-st
hh1=int(Total/3600)
mm1=mm1=int((Total%3600)/60)
ss1=(Total%3600)%60
printf “Total Up Time: %2d:%02d:%02d\n” ,hh1,mm1,ss1
}’
create a file called sleeptime.sh with the following line
cat /var/log/user.log.1 /var/log/user.log|/nfs/George/sleep.awk
I put these files in /nfs/George. You can then just
sh sleeptime.sh
It will display the sleep times in a more readable format.
RAC