Tag Archives: strace

System call tracing; strace with pid

Copied directly from ubuntu wiki, want to store here so I dont lose it

strace -Ff -tt -p <PID> 2>&1 | tee strace-<program>.log

edit: better way that creates a file per process/child process

strace -f -ff -tt -p <PID> -o strace.log

This will create files for each child process in addition to the main process, named strace.log.<PID>

Using strace to analyze apache

For times that you want to know exactly what a process is doing (for instance, if your apache is Pleskified and you’re getting weird website errors that can’t be traced back to any of your own code…) you can use strace.

 service apache2 stop

strace -f -o trace.txt /etc/init.d/apache2 start&nbsp; # this will run strace on all child processes of apache, so you don't need to worry about figuring out the correct process

## do whatever to generate the error message (in my case, just accessing the site)

service apache2 stop

## use htop to verify the strace has stopped

service apache2 start

Then check trace.txt to find your issue!

And have a look here for a more thorough tutorial.