2

I can use a program like top to periodically update system statistics and I can use lsof -p <pid> | wc -l to give me a snapshot of the number open files for a process. Is there a command I can call that, like top, will periodically show me the number of open files for a process, updated every second or so?

4

Check out watch, if all you need is to call a command like lsof -p <pid> | wc -l periodically.

http://ss64.com/bash/watch.html

Edit:

Or just write a simple bash script that repeats a command periodically.

#!/bin/bash
while true
do
  lsof -p <pid> | wc -l
  sleep 2
done
| improve this answer | |
  • Thanks. However, watch does not appear to be available on Mac OS X. – ericg Sep 21 '11 at 10:06
  • You can download and compile watch yourself, but I guess it's quicker to write a bash script :) – Jin Sep 21 '11 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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