Cron/ssh to remove folders older than X days

I’m trying to write a cron/ssh to remove recursive folders in a “data” folder that is older than X days.

I’ve been able to remove files, but not folders.

This is the code I have so far, but if someone can point out how to remove folders older than X days, that’d be great.

# this should remove files older than 2 days.
find /path/to/data/ -name '*' -type f -mtime +2 -exec rm -v -r -i {} \\;

What I’m trying to do is the following;

Recursively Delete folders inside the data folder older than 3 days


Gets rid of all pdf’s older than 60 days:

find /path/to/files -mtime +60 -type f -name "*.pdf" -exec rm {} \\; > /dev/null 2>&1

Thanks for your help, hopefully it will help me resolve my issue.


This is a better solution, thanks to;

# delete files/folders older than 3 days
find /path/to/inbounddata/data/* -depth -type d ! -name data -mtime +3 -exec /bin/rm -Rf "{}" \\;