Getting Uptime In Yocto Or Older Linux Machine – Linux Tips And Tricks

Getting Uptime In Yocto Or Older Linux Machine – Linux Tips And Tricks

HomeOther ContentGetting Uptime In Yocto Or Older Linux Machine – Linux Tips And Tricks
ChannelPublish DateThumbnail & View CountActions
Channel Avatar Rabi Gurung2023-03-23 14:30:11 Thumbnail
367 Views
Discover how you can get uptime in Yocto or older Linux machines.

Get When the system got reboot (in newer Linux machines)
uptime -s

cat /proc/uptime

OUTPUT
1812083.86 2618211.11

The First number is the total number of seconds the system has been up.
The Second number is how much of that time the machine has spent idle, in seconds.

Get only the uptime
cat /proc/uptime | cut -d’ ‘ -f1 | cut -d’.’ -f1

OUTPUT
1811896

Formatted Date
eval /”echo $(date -ud /”@$(cat /proc/uptime | cut -d’ ‘ -f1 | cut -d’.’ -f1)/” +’$((%s/3600/24)) days %H hours %M minutes %S seconds’)/”

OUTPUT
20 days 23 hours 19 minutes 54 seconds

#linux #ubuntu #redhat #bash

Please take the opportunity to connect and share this video with your friends and family if you find it useful.