What directory PHP is busy with

The file “cwd” under /proc/pid is a symbolic link to the “current working directory”:

for i in `ps -ef | awk '/php/{print $2}'`
do
ls -l /proc/${i}/cwd
done

The result is:

lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:40 /proc/11544/cwd -> /home/alekz/public_html/blog/wp
lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:40 /proc/11764/cwd -> /home/alekz/public_html/alekz.net
lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:40 /proc/12574/cwd -> /home/alekz/public_html/alekz.net
lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:40 /proc/13081/cwd -> /home/alekz/public_html/alekz.net
lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:45 /proc/15053/cwd -> /home/alekz/public_html/blog/wp
lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:45 /proc/15056/cwd -> /home/alekz/public_html/blog/wp
lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:49 /proc/15696/cwd -> /home/alekz/public_html/blog/wp/wp-content/plugins/si-captcha-for-wordpress/captcha-secureimage

Of course, you can use any other process name instead of php.

And here’s a “dynamic” version:

while true
do
clear
for i in `ps -ef | awk '/php/{print $2}'`
do
ls -l /proc/${i}/cwd
done
sleep 5
done