Linux Delete Files Older Than 3 Months Bash

Posted on October 28, 2020 at 11:15 pm

This bash command will print all files older than 3 months:

find /path/to/root/folder/*.log -type f -mtime "+$(( ( $(date '+%s') - $(date -d '3 months ago' '+%s') ) / 86400 ))" -print

Use -delete to delete all matches:

find /path/to/root/folder/*.log -type f -mtime "+$(( ( $(date '+%s') - $(date -d '3 months ago' '+%s') ) / 86400 ))" -delete

Receive updates via email

Other Posts

Updated Posts