#!/bin/sh while [ 1 ]; do TIMESTAMP=`date +"%s"` # make sure it's not the parent apache process # PID_APACHE=`ps ax | grep "/usr/sbin/apache" | grep -v ssl | grep -v grep | awk '{print $1}' | head -1` PID_APACHE=`pstree -p | grep apache | head -5 | tail -1 | cut -d '(' -f 2 | cut -d ')' -f 1` echo "Grabbing: $PID_APACHE in /home/mlutfy/strace-$TIMESTAMP" strace -o /home/mlutfy/strace-$TIMESTAMP -p $PID_APACHE echo "Process died. Moving on." done