---
title: Cleaning up with clearing rake tasks
author: Daniel Schoppmann
tags: Rails
published_at: '2024-07-23T09:00:00+02:00'
updated_at: '2024-07-23T16:58:41+02:00'
canonical_url: https://www.dotruby.com/articles/cleaning-up-with-clearing-rake-tasks
---

# Cleaning up with clearing rake tasks

Learn how to easily cleanup your Rails `log` and `tmp` files.

It's like anywhere else in life: If you do a lot of crafting, you're going to get dust, and you're going to have to clean it up from time to time. Otherwise, it's a mess to work in. 
As developers, we tend to have a good eye for refactoring, but do we have the same eye for our logs?

Especially in development: Every requests is logged, every request might create cache files, every test run might produce screenshots etc. 
In large Rails application, the local `log` and `tmp` directories can grow quite large. When was the last time you checked for the file size of your local log files?

```bash
du -hc */**/*.log
```

Don't be surprised to see quite large numbers here. It's a good thing that Rails comes with practical clearing tasks - in the form of rake tasks:

```bash
# Truncate all/specified *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)
bin/rails log:clear

# Clear cache, socket and screenshot files from tmp/ (narrow w/ tmp:cache:clear, tmp:sockets:clear, tmp:screen...
bin/rails tmp:clear
```

The description speaks for itself. 

**Hint**: If your Rails app already runs on Rails 7.1 or higher, there is also a new `log_file_size` [config](https://guides.rubyonrails.org/configuring.html#config-log-file-size) available now. It defaults to 100 MB in the development and test environment.

So always keep an eye for large files in your local app environment!
