0

I want to do a /home search and remove for files named error_log that are over 5mb

I use this now but it doesn't factor space:

find /home -type f -name error_log -exec rm -f {} \;

Any idea how to add the 5 mb limit here?

Thanks!

3
Contributors
3
Replies
37
Views
2 Years
Discussion Span
Last Post by mouaadable
1

You could use a python script named lescript

#!/usr/bin/env python3
# -*-coding: utf8-*-
import os
import sys

if __name__ == '__main__':
    size = int(sys.argv[1])
    for filename in sys.argv[2:]:
        if os.stat(filename).st_size > size:
            try:
                os.unlink(filename)
            except:
                print('Ignoring', filename)

Then invoke

find /home -type f -name error_log -exec lescript 5242880 {} +
3

Awesome, I think I found a way like this:

find /home -size +5m -type f -name error_log -exec rm -f {} \; | sort -u

I'm going to try these too though, thanks again.

0

use Ccleaner disk analyze option, and when if finish analyzing scroll down until you find 5 mb files and start looking by file name, this is an alternatif way of doing it ..good luck mate.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.