Often, you find that log files are taking too much disk space. You want to delete them efficiently
find /path/to/log/directory -type f -mtime +180 | xargs rm
This command will delete all files older than 180 days in /path/to/log/directory
. If you know your log files' name pattern, it's better to specify that pattern in the find
command.
You probably don't want to do this manually everytime. So add it to cronjob
0 0 1 * * find /path/to/log/directory -type f -mtime +180 | xargs rm > /dev/null 2>&1