The following line deletes all files modified more than 14 days ago matching the pattern *.log under the directory /logdir:
Code:
find /logdir -name '*.log' -mtime +14 -exec /bin/rm {} \;
The command is recursive so it descends all directories under /logdir.
You can a list of the files that would be deleted by doing:
Code:
find /logdir -name '*.log' -mtime +14 -exec ls -l {} \;
I'd strongly recommend doing this first.
The following delete ALL files under /logdir over 14 days:
Code:
find /logdir -mtime +14 -exec /bin/rm {} \;
|