Delete files older than X days
Delete Log Files with -mtime PDF Print E-mail
Written by Administrator   
Sunday, 15 March 2009 01:30
  1 

  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
Be really careful as these are powerful commands which blow away files 
  wholesale.
 
Note: 
To find files created more than 5 days use -mtime +5
To find files created less than 5 days use -mtime -5
  
For log files older than 5 days
find /opt/app/logs/ -name *.log -mtime +5 -exec ls -tl {} \; 
find /opt/app/logs/ -name *.log -mtime +5 -exec rm -f {} \;

For log files newer than 5 days
find /opt/app/logs/ -name *.log -mtime -5 -exec ls -tl {} \;
find /opt/app/logs/ -name *.log -mtime -5 -exec rm -f {} \;

Comments
Search
Only registered users can write comments!

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

Last Updated on Thursday, 16 April 2009 22:15
 

Founder MJ12Net

Founder MJ12Net.org

Brian Bills
Founder MJ12Net
System Admin

Stumble Us

Valid XHTML & CSS | Template Design ah-68 | Copyright © 2009 by Firma