lsof
:
Try doing this as a starter :
lsof -p <PID>
this command will list all currently open files, fd, sockets for the process with the passed process ID.
For your special needs, see what I can offer as a solution to monitor a php script :
php foo.php & _pid=$!
lsof -r1 -p $_pid
kill %1 # if you want to kill php script
strace
:
I recommend the use of strace
. Unlike lsof
, it stays running for as long as the process is running. It will print out which syscalls are being called when they are called. -e trace=file
filters only for syscalls that access the filesystem:
sudo strace -f -t -e trace=file php foo.php
or for an already running process :
sudo strace -f -t -e trace=file -p <PID>