find path -type d -ctime +90 -exec rm -rf {} \;
explanation
根据文件属性,删除指定的多少日期前的文件
find
is the command
path
is the root directory you want to scan
-type d
means look for directories only
-type f
means look for files only
-ctime +90
means created time older than 90 days
-exec rm -rf {} \;
means remove recursively and force delete of the items which were found
-mtime
is modified time
参考文献
https://stackoverflow.com/questions/17945538/delete-directory-based-on-date
https://stackoverflow.com/questions/13489398/delete-files-older-than-10-days-using-shell-script-in-unix