Skip to content

Instantly share code, notes, and snippets.

@lsdr
Created July 15, 2010 00:57
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 lsdr/476348 to your computer and use it in GitHub Desktop.
Save lsdr/476348 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Stupid script that handles big Rails logs in search for activation emails queued on DelayedJobs.
# Like I said, stupid. No more than the bug that created the need to do this, but still.
#
# And nevermind the name. I decided to look the web for inspiration and got an article on Ford,
# Chrysler and Lee Iacocca. Thus, iacocca.sh.
#
echo "spliting log file in 30M tempfiles..."
split -b 30000000 $1
LOG_LIST=$(ls -1 x* | xargs)
USER_IDS=`pwd`/user_ids
for LOG in $LOG_LIST; do
echo "processing: $LOG"
grep -i delayed $LOG \
| grep -i create \
| grep -i activate \
| awk '/AR\:User\:([0-9]*)/ {print $32}' | \
sed 's/AR\:User\://' | sed 's/\\n\-//' >> $USER_IDS
echo " done $LOG, moving on..."
done
echo "removing tempfiles"
rm -fr x*
echo
echo "Success! Total of $(wc -l $USER_IDS)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment