The files opened by XYZ process can be found with the command

ls -l /proc/PID/fd

Is there anyway that can be done in a more interactive way like tail auto-refreshing every x seconds?

Thank you.

link|improve this question

80% accept rate
feedback

2 Answers

up vote 8 down vote accepted

Try the watch command:

watch -n 10 ls -l /proc/$$/fd

Watch is nice.

You could use an old school while loop:

while :
do
 ls -l /proc/$$/fd
 sleep 10
done

watch is in the procps package on debian based systems and the procps rpm on RedHat derived systems.

link|improve this answer
1  
works perfectly! Thank you! Just a minor typo, where it reads /prod change to /proc (let not some googler find your answers less worthy because he cant just copy-paste it!) ;) thks! – Frankie Jan 6 '11 at 12:47
1  
sleep itself can be used as condition in while loop, so your example can be written more elegantly like this: while sleep 10; do ls -l /proc/$$/fd; done – ipozgaj Jan 6 '11 at 12:55
feedback

You could combine lsofand watch.

For example watch "lsof -p 1234" will give you a list of all open files of pid 1234 every 2 seconds. You could change some parameters to meet your needs.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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