Wednesday, August 27, 2008

Processing Apache Access Logs

I need to keep track of who is logging in and using our project's issue tracking and wiki sites. I wanted a simple list of who has logged in on what day. I came up with the following command line to give me what I wanted.
cat access_log | awk '{ if ( $3 !~/-/ ) \
{print $3" " substr($4,2, index($4,":")-2 )} }' \
| sort | uniq
This gives me a list of users and login dates grouped by user as follows.
bambam 25/Aug/2008
barney 25/Aug/2008
barney 26/Aug/2008
fred 25/Aug/2008
fred 26/Aug/2008
fred 27/Aug/2008

No comments: