Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a little script that runs lsof on my laptop (Ubuntu Natty) every now and then to check for a few things. I recently noticed that it runs really slowly when I have Chromium or Firefox open.

Without Chromium open:

$ lsof | wc -l
5288

With:

$ lsof | wc -l
5721

Without:

$ time lsof > /dev/null

real    0m0.134s
user    0m0.080s
sys     0m0.040s

With:

$ time lsof > /dev/null 
real    0m20.250s
user    0m0.080s
sys     0m0.070s

lsof seems to get "stuck" when looking at the browser's entries.

I'm just curious why it's happening, and if there's a way around it. Suggestions?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Try the -n option:

-n This option inhibits the conversion of network numbers to host names for network files. Inhibiting conversion may make lsof run faster. It is also useful when host name lookup is not working properly.

share|improve this answer
3  
Correct. @Dane, you can run "strace lsof" and confirm that it's hanging on DNS resolution. –  MrTuttle Jul 11 '11 at 21:46
    
@MrTuttle Yeah, that's where it was getting stuck. write(4, "RESOLVE-ADDRESS 10.247.19.241\n", 30) = 30 read(4, <-- that's where it halted for a while. –  Dane Larsen Jul 12 '11 at 17:46
    
@jftuga Thanks! –  Dane Larsen Jul 12 '11 at 17:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.