Skip to content

Instantly share code, notes, and snippets.

@wayneeseguin
Forked from kennethkalmer/clear-rails-logs.sh
Created August 10, 2009 23:41
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 wayneeseguin/165491 to your computer and use it in GitHub Desktop.
Save wayneeseguin/165491 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Find all the rails projects from this directory down and clear their log
# files to save some space.
#
base=`pwd`
for path in `find $base -type f -path '*/config/environment.rb'` ; do
rails_root=`echo $path | xargs dirname | xargs dirname`
echo "Found RAILS_ROOT in $rails_root"
# can use pushd/popd to simplify.
pushd $rails_root
# Can run as a background task so that the script runs faster
# a caution is that if you have a lot of Rails projects then
# this will cause quite a few processes to be spawned :)
rake log:clear &
popd
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment