Purge log files in `/var/log` directory
Log yourself as root with: sudo -s
.
# to see the list
find /var/log -maxdepth 1 -type f -name '*.log'
# to purge files to zero byte
find /var/log -maxdepth 1 -type f -name '*.log' -exec sh -c '> {}' \;
You can use
find
with size flag-size +32M
to find files larger than 32MegaBytes
It's safe to assume to delete .gz
files in that directory.
Then do
find /var/log -maxdepth 1 -type f -name '*.gz' | xargs rm
It’s possible if you see
rm: missing operand
then means:
rm
didn't receive arguments sincefind
could not find.gz
files.