Monday, March 22, 2010

Using AWK to split syslog files by proc id

When troubleshooting a multi-threaded server it's sometimes nice to be able to split up the resulting log file by process making it a little bit easier to figure out what's going on. In this instance I'm splitting the log files from PostgreSQL by process ID which happens to be field 4.

# input format: 2010-01-25 15:41:46 PST [6534]: [30900-1] LOG:  duration: 0.243 ms  statement: SELECT ...

awk '{print > "substr($4, 2, length($4) - 3)"}' enroll.log

Print this post

No comments: