cancel
Showing results for 
Search instead for 
Did you mean: 

lsof takes long time ,

Shabahang
Occasional Advisor

lsof takes long time ,

Hello ,
I am using lsof for monitoring purposes.
once its executed , it takes about 2 min , whether Its on / , /var , a tiny sub Dir, or even a file .
is it normal ?
how can I reduce the load of lsof. it takes 99% of a core for 2 min !!!

5 REPLIES
Dennis Handly
Acclaimed Contributor

Re: lsof takes long time ,

lsof must look at all processes' open files to determine what is being used. Don't expect it to be fast, that's not its purpose.

What is it that you are monitoring?
Patrick Wallek
Honored Contributor

Re: lsof takes long time ,

What is the exact 'lsof' command you are running?

If you are just running 'lsof' without any arguments, then it could take a while because it is looking at all processes.

Adding some options to narrow the scope of what lsof is looking at/for could help you.
Dennis Handly
Acclaimed Contributor

Re: lsof takes long time ,

>Patrick: Adding some options to narrow the scope

Right, either to look at specific PIDs or to exclude others.
Duncan Edmonstone
Honored Contributor

Re: lsof takes long time ,

Could be getting confused, but I thought I read somewhere that lsof was effected by the same problem that fuser had recently... se this thread:

http://h30499.www3.hp.com/t5/System-Administration/fuser-uses-too-much-CPU/m-p/4606069#M376266


HTH

Duncan


HTH

Duncan
Dennis Handly
Acclaimed Contributor

Re: lsof takes long time ,

>Duncan: I read somewhere that lsof was effected by the same problem that fuser had recently

It depends. (The memory leak was in dld.sl) That was for PA only. If you could get lsof to skip looking at memory regions, that might help. Looking for mapped files requires looking at memory regions.