Difference between revisions of "Delete files older than x days"

From Tech-Wiki
Jump to: navigation, search
Line 2: Line 2:
  
 
To exclude files older than 30 days:
 
To exclude files older than 30 days:
  find /var/log -type f -mtime +30 -exec rm {} \;
+
  find /var/log -type f -name '*.log' -mtime +30 -exec rm {} \;

Revision as of 15:10, 12 September 2019


To exclude files older than 30 days:

find /var/log -type f -name '*.log' -mtime +30 -exec rm {} \;