Jackzz
Jackzz

Reputation: 1467

Fifth column of /proc/loadavg?

I came across several discussions(linux /proc/loadavg) and articles telling that the fifth column of /proc/loadavg is the process id of the most recent process. But I couldnot find a folder in the /proc filesystem with that PID. Also on trying cat /proc/loadavg the fifth column goes on increasing sequentially each time.

Why is it so?

Upvotes: 3

Views: 1731

Answers (2)

hek2mgl
hek2mgl

Reputation: 157937

The last value is the pid of the currently active process (while showing the contents of /proc/loadavg) which is likely a cat process

cat /proc/loadavg

which has already terminated while you are reading the results on screen.


Update:

I played around with it to prove that it is indeed the cat process. I simply used less, kept it open and tried to investigate the proc file system. I can only say the pid shown in loadavg was not the PID of less which I thought. Still true is what I said: the process listed there is current active process and it has been terminated already. But it seems not the PID of the cat process.

Upvotes: 4

Dilip Kumar
Dilip Kumar

Reputation: 1746

The proc filesystem is a pseudo-filesystem whose files provide an interface to kernel data structures, and is usually mounted as /proc. The /proc/loadavg provides the current calculated average load of the system. These values represent the average system load in the last 1, 5 and 15 minutes, the number of active / total scheduling entities (tasks) and the PID of the last created process in the system.

sample output

cat /proc/loadavg 
1.46              1.16            0.91            2/321             6220
 ^                  ^               ^                ^                  ^
 |                  |               |                |                  |
system load         |               |                                   
in last 1 min       |               |        Number of active/      PID of
                                    |        scheduled entities     last created process 
              system load           |               
              in last 5 min         |
                                    |
                              system load          
                              in last 15 min 

Also on trying cat /proc/loadavg the fifth column goes on increasing sequentially each time.

It represents the last created PID in the system. your cat command is also an process, so each time it varies. The process will terminate by the time you check in /proc.

Since so many process will be created/ deleted and the fifth field will be updated every time you do cat /proc/loadavg.

Upvotes: 4

Related Questions