Quick Tip to Clean Up Rails Logs

Every few months I use this command to empty each and every one of my test.log and development.log files in the src folder of my laptop:

find ~/src \
  -maxdepth 6 \
  -type f \
  -mindepth 1 \
  \( -name "test.log" -or -name "development.log" \) \
  -exec truncate -s 0 {} \;

It works by…

  1. Finding files that match the name
  2. Using the truncate command to reduce the size of the file to 0 bytes

Instead of typing it out each time, I’ve created a quick alias in my .bash_profile when my shell loads:

alias truncate_devlogs='find . -maxdepth 6 -type f -mindepth 1 \( -name "test.log" -or -name "development.log" \) -exec truncate -s 0 {} \;'

Then when I remember to do so, or I wrap up work on a project, a quick truncate_devlogs recoups disk space and makes me feel better.

 
3
Kudos
 
3
Kudos

Now read this

Fix ESLint crashing on rest operator: “Cannot read property ‘type’ of undefined”

This is a bit of an obscure one, but I tend to use the same dev tooling configuration (Prettier, ESLint, Babel, etc) for multiple projects so I’m likely to run into this again. I encountered this in the middle of a project after a VSCode... Continue →