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?
Asked
Active
Viewed 1,401 times
2
ericg
- 544
- 2
- 6
- 16
1 Answers
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
u1686_grawity
- 426,297
- 64
- 894
- 966
Jin
- 4,323
- 27
- 31
-
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