Jump to content

How to cron delete folders with a certain name and older than 72 hours old?

Recommended Posts

This should list matches in the current directory older than 3 days:


 find . -mtime +2 -name "\$esnp" -print


Change -print to -delete if you're absolutely sure. Test, test, test with -print to make certain.


Edit: (good gosh, proofread!) To delete multiple directory levels you need to work from the bottom up with the -depth option. This would do that from /var/log on down (from the bottom up):


 find /var/log -depth -mtime +2 -name "\$esnp" -print


Here's the dangerous version. It doesn't need -depth since that's implied with -delete:


 find /var/log -mtime +2 -name "\$esnp" -delete


Anywhere close?

Link to comment


This topic is now archived and is closed to further replies.

  • Create New...