How do I Delete all log files smaller than a certain size?

Tell everybody, what you think about SafeSquid!
Speak your mind!
India umashankar
Posts: 13
Joined: Wed Apr 24, 2019 7:18 am

How do I Delete all log files smaller than a certain size?

Post by umashankar » Thu Oct 01, 2020 8:32 am

In some situations like, when SafeSquid service has been hanged at some heavy load conditions, then some '0 or 20'k log files are generated.

You can remove those unnecessary log files with no data using below command.

Code: Select all

find ./ -type f -size 0  -delete

Code: Select all

find ./ -type f -size -20k  -delete
Note the - before 20k. Just 20k means exactly 20 kilobytes. -20k means smaller than 20 kilobytes. +20k means larger than 20 kilobytes.
The -type 'f' forces the command to only act on files and skip directories.