Uptime Command In Linux: It is used to find out how long the system is active (running). This command returns set of values that involve, the current time, and the amount of time system is in running state, number of users currently logged into, and the load time for the past 1, 5 and 15 minutes respectively.
[mistersubha@server-1 ~]$uptime 08:24:37 up 207 days, 11:10, 0 users, load average: 0.00, 0.03, 0.05
From the above code, the output has got four parts: Current time, Uptime, Number of Users, and average load as mentioned earlier.
uptime has got few options to tailor outputs and to those who are unaware of the options of the newbies working with uptime can use the option “-h” (which means help). This will give the options available to the preceding command.
[mistersubha@server-1 ~]$uptime -h Usage: uptime [options] Options: -p, --pretty show uptime in pretty format -h, --help display this help and exit -s, --since system up since -V, --version output version information and exit For more details see uptime(1).
Just to make sure you get the uptime in human-readable format, you can use option “p”
[mistersubha@server-1 ~]$uptime -p up 29 weeks, 4 days, 11 hours, 1 minute
Option “s” is used to get the starting time/specified time when the system started has been running.
[mistersubha@server-1 ~]$uptime -s 2017-11-10 20:14:15
Version information can be shown using option “V”.
[mistersubha@server-1 ~]$uptime -V uptime from procps-ng 3.3.10
There are few other ways to find the uptime and output header of command “w” is similar to that of output of “uptime” command.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.