How do I show the path of the php script running in the ps command in linux?

Question:

How do I find out the script path (ex: /var/www/html/script.php ) of the PHP PID by the linux ps command?

I'm in big trouble, there's some PHP script consuming a lot of memory and cpu, when I give ps aux | grep php it appears only the example pool processes

nginx    21155  1.0  1.6 477684 63380 ?        S    16:31   0:39 php-fpm: pool www
nginx    21156  0.8  3.9 568248 154148 ?       S    16:31   0:32 php-fpm: pool www
nginx    21157  1.0  1.7 480764 66968 ?        S    16:31   0:37 php-fpm: pool www
nginx    21158  1.2  1.9 484240 75068 ?        S    16:31   0:44 php-fpm: pool www
nginx    21159  1.1  1.9 486336 74312 ?        S    16:31   0:40 php-fpm: pool www
nginx    21160  0.6  1.8 485456 70972 ?        S    16:31   0:25 php-fpm: pool www
nginx    21161  0.9  2.0 487224 78984 ?        D    16:31   0:36 php-fpm: pool www
nginx    21162  1.0  1.7 478156 67684 ?        S    16:31   0:39 php-fpm: pool www
nginx    21164  0.6  1.5 471500 60624 ?        D    16:31   0:25 php-fpm: pool www
nginx    21165  0.9  1.7 481596 66960 ?        S    16:31   0:34 php-fpm: pool www
nginx    21166  1.0  1.8 480052 71864 ?        S    16:31   0:37 php-fpm: pool www
nginx    21167  0.7  1.8 481836 71564 ?        S    16:31   0:26 php-fpm: pool www
nginx    21168  1.0  1.8 483484 69868 ?        S    16:31   0:38 php-fpm: pool www
nginx    21169  0.9  1.8 485384 71716 ?        S    16:31   0:35 php-fpm: pool www
nginx    21170  1.0  1.8 483724 69524 ?        D    16:31   0:37 php-fpm: pool www
nginx    21171  0.8  1.5 474424 61632 ?        S    16:31   0:30 php-fpm: pool www
nginx    21172  0.8  1.8 483320 71272 ?        S    16:31   0:30 php-fpm: pool www
nginx    21173  1.2  1.5 472400 61100 ?        S    16:31   0:45 php-fpm: pool www
nginx    21174  1.0  2.0 495396 80996 ?        S    16:31   0:38 php-fpm: pool www
nginx    21175  0.9  2.0 487964 77956 ?        S    16:31   0:34 php-fpm: pool www
nginx    21176  0.9  1.5 468000 58228 ?        S    16:31   0:35 php-fpm: pool www
nginx    21177  0.9  1.8 482432 72588 ?        S    16:31   0:34 php-fpm: pool www
nginx    21178  0.9  2.1 497256 82992 ?        S    16:31   0:34 php-fpm: pool www
nginx    21179  0.7  1.6 476880 62252 ?        S    16:31   0:27 php-fpm: pool www
nginx    21180  1.1  1.4 468284 56892 ?        S    16:31   0:40 php-fpm: pool www
nginx    21181  0.7  1.8 482504 71716 ?        S    16:31   0:29 php-fpm: pool www
nginx    21182  1.2  1.8 479800 69896 ?        S    16:31   0:46 php-fpm: pool www
nginx    21185  0.8  1.9 480388 73480 ?        S    16:31   0:29 php-fpm: pool www

In case I needed to know the path this process is running, a simple example.

   nginx    21185  0.8  1.9 480388 73480 ?        S    16:31   0:29 php-fpm:      pool www (Caminho do script: /var/www/html/script.php).

Is there any way to do this?

Answer:

Maybe this will help you

$ sudo ls -l /proc/PID/exe

In the example below I look for adb:

$ ps aux | grep adb
root      7811  0.0  0.0  30424  2468 pts/12   S+   18:03   0:00 adb logcat

$ sudo ls -l /proc/7811/exe
lrwxrwxrwx 1 root root 0 Jan 23 18:25 /proc/7811/exe -> /usr/lib/android-sdk/platform-tools/adb
Scroll to Top