Hi all,
I need to get the restart and login duration of each Mac.
I've made a script that looks in the system.log file after reboot.
Is there a better way to get these two values?
Any advice is welcome
Best regards,
joe
#!/bin/sh
time1=$(grep "BOOT_TIME" /var/log/system.log | tail -n 1 | awk '{print $3}')
time2=$(grep "Login Window Started Security Agent" /var/log/system.log | tail -n 1 | awk '{print $3}')
time3=$(grep "User info context values set for" /var/log/system.log | grep SecurityAgent | tail -n 1 | awk '{print $3}')
time4=$(grep "Initialized sandbox" /var/log/system.log | grep fmfd | tail -n 1 | awk '{print $3}')
echo "BOOT_TIME : $time1"
echo "LoginWindow : $time2"
echo "User info context : $time3"
echo "Initialized sandbox : $time4"
sec1=$(date -j -f "%T" $time1 "+%s")
sec2=$(date -j -f "%T" $time2 "+%s")
sec3=$(date -j -f "%T" $time3 "+%s")
sec4=$(date -j -f "%T" $time4 "+%s")
diff1=$(($sec2-$sec1))
diff2=$(($sec4-$sec3))
echo "BOOT duration: $diff1 sec"
echo "LOGIN duration: $diff2 sec"