this could be a duplicate but I couldn't find the proper answer. Recently my server has been reporting high CPU usage and I want to find out what was causing that. When I used htop it showed me a bunch of apache2 processes so I guess one of my PHP scripts is probably being served however I would like to know which script exactly is causing that. Is there any way to do that? I'm running Ubuntu 14.04.
You can use follow option with the
tail command. eg.
tail -f /var/log/apache2/other_vhosts_access.log
Then you almost can see which files are served in realtime.
You can also
tail -f the other relevant files in the same location:
You could also get a more detailed realtime view from the command line via goaccess.