October 9, 2015

Strace Multiple Processes

To get debugging information about a running process when your log files aren’t showing you enough information it can be useful to use the strace command. The problem is if you’re running a process with multiple children then you’ll need to add each of the process ids (PIDs) to be traced. First off, make sure it’s installed:

apt-get install strace

Now let’s look for an example process and strace all of the process children to get the current output:

ps auxw | grep php-fpm | awk '{print"-p " $2}' | xargs strace 2>&1 | grep -v poll | grep -v clock_gettime

As you can see in the above command, we looked for php-fpm using ps, pulled the IDs of all the running children and straced the result. This will give you a live stream of what the processes are currently doing.

Leave a Reply

Your email address will not be published. Required fields are marked *