I have a script to clean out old files and directories in a log area like:
find . -mtime +${NUM_DAYS} -type d -exec rm -rf '{}' \;
However if I run this 2 levels up from the files that have changed it will often show the parent directory because the time stamp isn't changed by changes in a sub-directory
Is there a way I can use find (or something else) so I don't try and delete the parent directory?
For example if I have the file system:
# ls -ld /var
drwxr-xr-x 24 root root 4096 Aug 16 2010 /var
# ls -ld /var/net-snmp/
drwx------ 2 root root 4096 Aug 28 15:49 /var/net-snmp/
# ls -l /var/net-snmp/
total 4
-rw------- 1 root root 1174 Aug 28 15:49 snmpd.conf
Running my find command from / with will try to recursively remove /var, even if NUM_DAYS is set so that Aug 28 is within my time scale