Skip to content

Instantly share code, notes, and snippets.

@roblogic
Last active October 16, 2017 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roblogic/b267a8da77ba172ff3cdf6a03b4e4d9c to your computer and use it in GitHub Desktop.
Save roblogic/b267a8da77ba172ff3cdf6a03b4e4d9c to your computer and use it in GitHub Desktop.
Trace process thread in a log file
#!/bin/sh
# test script
# trace Web Service logic by process id
# e.g. paxservices-CEB2.0-1435811146723-211
USAGE='Usage: tracelog <logfile_name> <process_id>'
[ $2 ] || { echo $USAGE ; echo ; exit ; }
LOGFILE_NAME=$1
PROCESS_ID=$2
# find the process thread
TOP=`grep -a -n $PROCESS_ID $LOGFILE_NAME | head -1 | awk -F: '{print $1}'`
BOT=`grep -a -n $PROCESS_ID $LOGFILE_NAME | tail -1 | awk -F: '{print $1}'`
sed -n "${TOP},${BOT}p" $LOGFILE_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment