monitor open process files on linux (real-time)
Solution 1:
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.
Solution 2:
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
Solution 3:
You could combine lsof
and 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.