Skip to content

Instantly share code, notes, and snippets.

@chriskottom
Created November 13, 2010 13:19
Show Gist options
  • Save chriskottom/675312 to your computer and use it in GitHub Desktop.
Save chriskottom/675312 to your computer and use it in GitHub Desktop.
simple Rake task for cleanup of Rails directory
namespace :admin do
desc "Clean up all temporary files in the application directory"
task :cleanup, :needs => :environment do
puts "Removing temporary directory contents"
tmp_files = []
%w{ cache pids sessions sockets }.each do |dir|
tmp_files += Dir.glob( File.join(Rails.root, "tmp", dir, "*") )
end
File.delete(*tmp_files)
puts "Removing log files"
log_files = Dir.glob( File.join(Rails.root, "log", "*") )
File.delete(*log_files)
puts "Removing emacs temporary files"
emacs_tmp_files = Dir.glob( File.join(Rails.root, "**", "*~") )
emacs_tmp_files += Dir.glob( File.join(Rails.root, "**", "\#*\#") )
File.delete(*emacs_tmp_files)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment