Will this work to delete files 30 days old in $backupDir or is there a better way to do it?
find $backupDir -type f -mtime +30 -exec rm {} \;
Will this work to delete files 30 days old in $backupDir or is there a better way to do it?
find $backupDir -type f -mtime +30 -exec rm {} \;
If you have a lot of old files to remove, this may be noticeably faster:
find $backupDir -type f -mtime +30 -exec rm {} +
When you terminate the -exec
primary with a semicolon, you invoke rm
once for each pathname to be removed; with a plus sign, rm
will be passed a group of pathnames to remove.
Cool. Thanks for the explanation!