3

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?

1 Answer 1

8

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.

2
  • 4
    Correct. @Dane, you can run "strace lsof" and confirm that it's hanging on DNS resolution.
    – MrTuttle
    Jul 11, 2011 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. Jul 12, 2011 at 17:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .