Skip to content

Instantly share code, notes, and snippets.

@ymkim92
Last active July 1, 2021 22:23
Show Gist options
  • Save ymkim92/6f8a4e6909f4fdfb2384cbec06947202 to your computer and use it in GitHub Desktop.
Save ymkim92/6f8a4e6909f4fdfb2384cbec06947202 to your computer and use it in GitHub Desktop.
Clean up the big size logs in /var folder

Clean up the big size logs in /var folder

When I compiled tdesktop through docker, I met an error of "out of space". After I spent some time I found it was because the docker wrote a lot of logs in /var folder.

To clean up the logs, you can follow these steps:

  • Find the big size files in /var/lib/docker.

    find /var/lib/docker -size +10M
    or
    find /var/lib/docker -size +100M
    
  • The files in /var handled by syslogd or any other similiar one. So you need to do this instead of removing the file.

    cat /dev/null > found_big_size_file
    

To make it automatic, you can do this:
find /var/lib/docker -size +10M | xargs -I % sh -c 'cat /dev/null > "%"'

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment