Server Uptime Command To Find Out How Long The System Has Been Running

by on January 4, 2006 · 13 comments· LAST UPDATED January 20, 2011

in

I'd like to find out how long the system has been running under UNIX or Linux operating system. How do I find out system uptime?

Both Linux and UNIX like systems comes with various command to find out server uptime command. Under Linux file /proc/uptime has uptime information and file /var/run/utmp has information about who is currently logged on. However, information from /proc or utmp file is not directly readable by humans so you need to use the following commands.

UNIX / Linux uptime command

Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following commands:
$ uptime
Sample outputs:

 21:54:11 up 13 days,  4:29,  1 user,  load average: 0.21, 0.21, 0.12

The uptime command gives a one line display of the following information.

  • The current time (21:54:11)
  • How long the system has been running (up 13 days)
  • How many users are currently logged on (1 user)
  • The system load averages for the past 1, 5, and 15 minutes (0.21, 0.21, 0.12)

This is the same information contained in the header line displayed by the w and top commands:
$ w
Sample outputs:

 21:56:06 up 13 days,  4:31,  1 user,  load average: 0.03, 0.14, 0.09
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    123.xxx.yy.zzz    21:54    0.00s  0.02s  0.00s vi

$ top
Sample outputs:

Fig.01: UNIX uptime top command output

Fig.01: UNIX uptime top command output


Please note that the w command displays who is logged on and what they are doing while top command provides a dynamic real-time view of a running Linux/UNIX/BSD operating systems.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 13 comments… read them below or add one }

1 Onur Buyukceran July 22, 2007 at 1:39 am

my favorite :) updates every second….

top -d 1

Reply

2 Benjamin Alawani August 26, 2009 at 9:30 am

Nice looking site; useful and clear information. Good job!

Reply

3 Andy Konecny March 10, 2010 at 9:49 pm

The only problem with the uptime command is that it isn’t always obvious what units of measure to the time it has been up. Just a bit confusing for those new to it, especially those from the Windoze world trying to come over to Linux. Just fleshing out the units (up 5 hours:54 minutes (days:hours:minutes)) on this would certainly help in bringing more over, especially if we can get into the man&info pages.

Reply

4 Mohamed November 28, 2010 at 4:57 am

$ uptime
07:55:56 up 3 days, 17:37, 6 users, load average: 0.04, 0.06, 0.01
$

by default it will give how many days the OS is up, and how many hours:mins.
if it less than 1 day, it will give only hours:mins.

Reply

5 Anwar December 3, 2010 at 8:33 am

Wonderful.

Reply

6 Ravi May 10, 2011 at 1:24 pm

Hi,

How do I get only time information excluding other load information

Thanks,
Ravi.

Reply

7 joe April 19, 2012 at 6:18 pm

How do I get only time information excluding other load information

# 1. run Command
# 2. strip unneeded leading data
# 3. check if the uptime is greater than 24 hours
# 4. make the output human readable
# 5. trim any leading space

uptime | \
sed s/^.*up// | \
awk -F, '{ if ( $3 ~ /user/ ) { print $1 $2 } else { print $1 }}' | \
sed -e 's/:/\ hours\ /' -e 's/ min//' -e 's/$/\ minutes/' | \
sed 's/^ *//'

Reply

8 Igor September 3, 2012 at 9:37 am

For people who want to get uptime within a C program I would suggest having a look at sysinfo() too…

Reply

9 mk March 15, 2013 at 8:56 pm

nice and so useful
thank you

Reply

10 Brookly April 3, 2013 at 3:16 pm

How can i know uptime of a server machine without logging in it ?? Is there any way?

Reply

11 kunal July 15, 2013 at 1:47 pm

Hello Buddies , plz specify whats the value ’4:29′ in the above output.

Reply

12 Pradeep January 27, 2014 at 1:02 pm

@Kunal It’s 4 hours and 29mins. So from the output the server uptime is 13 days, 4 hours and 31 mins.

Reply

13 Viet August 13, 2014 at 12:02 am

thanks for this!

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: