Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Delete all directories more than a week old

user13681259Jun 13 2012 — edited Jun 14 2012
We would like to delete the directories more than 7 days from given location. we are using the below script/find command. but it is deleting the base directory as well.


HOTBACKUP_DIR=/u01/appluat/patches_OLD
export HOTBACKUP_DIR
for i in `find ${HOTBACKUP_DIR} -maxdepth 1 -type d -mtime +7 -print`; do echo -e "Deleting 7 days old directory $i"; -exec rm {} $i; done


HOTBACKUP_DIR=/u01/appluat/patches_OLD
export HOTBACKUP_DIR
for i in `find ${HOTBACKUP_DIR}/ -maxdepth 1 -type d -mtime +7 -print`; do echo -e "Deleting 7 days old directory $i"; -exec rm {} $i; done

the above script deleting the base directory "patches_OLD", becuase the base directory itself older than 7 days. We don't want to delete the base directory and would like to delet the directories older than 7 days under /u01/appluat/patches_OLD.

Please help
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 12 2012
Added on Jun 13 2012
4 comments
462 views