WebFaction
Community site: login faq

How would one go about using SSH to debug PHP? What if my PHP process is running slowly and other debugging methods like checking server load, using a debugging plugin, or MySQL logging are not available/not showing enough info?

asked 30 Jul, 00:27

johns's gravatar image

johns ♦♦
4.9k29
accept rate: 23%

edited 30 Jul, 00:32


For CGI each process is a new request, or visitor.

You can identify a running process by using strace and ps in SSH

First identify the PID of the process you want,

ps -u $USER -o pid,rss,command

Once you know the PID you can run strace, replace PID with the number from ps,

strace -tTvf -s 1024 -p PID

This will show you the first 1024 bytes and can typically show what the process is doing.

A simple shell script can be used to listen fo all php processes in real time,

while true
do
for i in $(pgrep php); do
    echo $i
    strace -tTvf -s 1024 -p $i >> out.txt
    sleep 600
done
done
permanent link

answered 30 Jul, 00:29

johns's gravatar image

johns ♦♦
4.9k29
accept rate: 23%

edited 30 Jul, 00:32

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×253

question asked: 30 Jul, 00:27

question was seen: 254 times

last updated: 30 Jul, 00:32

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM