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?

ericg
  • 544
  • 2
  • 6
  • 16

1 Answers1

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