I have situation where we have log files being saved in a /YEAR/MONTH/ folder structure, e.g. /2018/03/fakelog.tmp.gz
I'd like to have a cronjob run monthly to delete files older than a certain number of years, and instead of using say find I imagine it would be possible to make use of this structure to make things more efficient (with find -mtime it will take many many minutes to run).
I'm sure it'd be easy to get the current date and reduce the year by, say, 2 and then delete everything /2016/03/ but then we will miss anything in /2014/ or /2016/01 which could be a concern if the script is added to a different system, or for any reason doesn't run a specific month.
Is it possible to, for example, find any folders 'less than' 2016, or any folders 'less than' /2016/03 ? Or can this be solved in a different way that doesn't involve iterating through every combination.
Thanks for any help