Pages

Sunday, September 2, 2012

Resource Management : W & Uptime


W
If we need to find out how many and who are the users that are currently logged in to the linux system, we can use the 'w' command.

When we run the 'w' command like ,

[root@vx111a ~]# w
14:07:10 up  1:16,  2 users,  load average: 0.25, 0.14, 0.09
USER     TTY      FROM          LOGIN@   IDLE   JCPU   PCPU  WHAT
root      :0          -                12:52      ?xdm?  3:41   0.08s  /usr/bin/gnome-session
root       pts/1    :0.0            12:52        0.00s  0.01s  0.00s  w

The Output of the w command prints the activity on the system currently along with what each user is doing

=> The first line displays the current time of day
=> How long the system has been running
=> The number of users logged into the system
=> The load averages. The load average numbers give the number of jobs in the run queue averaged over 1, 5 and 15 minutes.

The Fields below shows
=>user's login name (USER)
=>the name of the terminal the user is on (TTY)
=>the host from which the user is logged in (FROM)
=>the time the user logged on (LOGIN@)
=>the time since the user last typed anything (IDLE)
=>JCPU is the time used by all processes attached to the tty. It does not include past background jobs, but does include currently running background jobs
=>PCPU is the time used by the current process, named in the "WHAT" field.
=>the name and arguments of the current process (WAHT)

Uptime
There is some times where we need to find out how long the system was up and running. Linux provides you various facilities to find this information. The Uptime information can be obtained from /proc/uptime like

[root@vx111a ~]# cat /proc/uptime
5272.09 5038.87

and file /var/run/utmp contains information about who is currently logged on. However, information from /proc or utmp file is not directly readable by humans .So linux provides us with a command 'uptime' to get information.

[root@vx111a ~]# uptime
14:34:04 up  1:43,  2 users,  load average: 0.08, 0.04, 0.01

=>The Current Time : 14:34:04
=>How long the system has been running : from 1 hour and 43 minutes
=>Users Currently Logged in : 2
=>The load average numbers give the number of jobs in the run queue averaged over 1, 5 and 15 minutes.