Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 9 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.

share|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

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.

share|improve this answer

If you want to see each file as it is being opened, you can filter that with strace. For example:

strace -p _pid_of_app_ -e trace=open,close
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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