When I run ps -ef
from the Linux command line I don't see the php scripts currently being run by Apache web users, I just see the process as:
/usr/bin/php5-cgi -q -b 127.0.0.1:9000 -c /etc/php5/cgi/php.ini
Is there a command line that will show which script is being run, rather than just the fact the Apache user is using php?
You can get the current working directory and opened files using lsof. Sadly this does not include the script being run, but if scripts are in different directories, or open different files, you can distinguish between them. Eg the following shows a script in /var/www/stuff/php is running:
sudo lsof -c http | grep cwd
httpd 24475 id cwd DIR 8,3 4096 1123403 /var/www/stuff/php
You can configure apache to let you have the information. Add an entry like
<Location /server-status>
SetHandler server-status
...
</Location>
in your conf ensuring it is only made available to restricted remotes.
Then browse to http://localhost/server-status
and you will have a "ps" of
running jobs. For example, this output shows gg.php is running (I've
removed some columns):
Srv PID Acc M CPU SS Slot Client VHost Request
0-0 23688 0/0/262 W 0.50 2 4.48 ::1 xxx:80 GET /php/gg.php HTTP/1.1
1-0 23743 0/0/187 W 0.00 0 3.30 ::1 xxx:80 GET /server-status HTTP/1.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With