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?
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?
Try the
watch
command:Watch is nice.
You could use an old school while loop:
watch
is in the procps package on debian based systems and the procps rpm on RedHat derived systems.If you want to see each file as it is being opened, you can filter that with
strace
. For example:You could combine
lsof
andwatch
.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.I created a bash file where I was writing the output of the command to a file. File was generated on the basis current date. Here I am counting number of open files.