-2

I have logged into school server which is running Solaris. I am to print the number of minutes from booting the server. I am using uptime and recieve this output

 8:05pm  up 12 day(s),  1:56,  11 users,  load average: 0.07, 0.11, 0.12

man uptimethrows different output , now I am confused. How can I retrieve the number of minutes since booting the server till printing it?

  • 12 days times 24 hours times 60 minutes, plus ... ? – Jeff Schaller Feb 24 '16 at 19:16
  • 2
    A day is 86400 seconds. Your field #3 is the number of days. field #5 is hours and minutes, 3600 and 60 seconds respectively. If you need the number of seconds since the boot up, it is a simple combination of several awk and if you wish cut commands with some arithmetic operation involved. – MelBurslan Feb 24 '16 at 19:18
2

One day not being necessarily 86400 seconds and uptime output varying depending on since how long the OS is running, here is an accurate way to get the number of minutes since last boot on Solaris:

kstat -n system_misc | 
    nawk '/boot_time/ {printf("%d minutes\n",(srand()-$2)/60)}'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.