Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php Activity log to see which files are being executed

Tags:

php

webserver

Is there any way to see active processes in PHP (like which files are being executed)?

like image 794
ASD Avatar asked Mar 01 '11 16:03

ASD


1 Answers

In linux you can install apachetop. This marvellous tool scans your webserver log files showing you which files are being called it has some excellent metrics like showing which ip's are access which scripts. or which are the most popular scripts and files being called.

Another option is to use lsof which lists open files, but as files are opened and closed rather quickly it may not really help

here is a command to watch all open php files

watch -n1 "lsof | grep '\.php'"

watch -n1 is a command that repeatedly runs a command every second

The command is lsof | grep '\.php'

which means list all open files and show only the ones with a .php in the filename

I have run this on a slow webserver and saw nothing, but I tested it and it does work. It may be that the scripts are being opened and closed so fast that the command misses them.

DC

like image 72
DeveloperChris Avatar answered Oct 04 '22 19:10

DeveloperChris