Sharing Knowledge | System Admin Articles

Delete old log files in Linux





Here is the quick command to delete the log files which are older than specified time in Linux


Be careful as these are powerful commands which blow away files completely.
  

Note: 
To find files modified more than 5 days use -mtime +5 and files modified less than 5 days use -mtime -5

Use -ctime parameter to find out the created time

To List and Delete log files older than 10 days, execute the following commands
 

find /var/log/ -name *.log -mtime +10 -exec ls -tl {} \; 
find /var/log/ -name *.log -mtime +10 -exec rm -f {} \;



Labels: Linux, Quick HOWTO

My Profile PhotoAbout the Author

I'm Parthiban, An UNIX System Admin by Profession. I'm Experienced in Linux/Unix System Administration and Scripting. I have done lot of work on the infrastructure Mgmt side in Linux, UNIX and Windows system administration, Hardware, Storage and Data center. I'm blogging since 2008.
Follow Me On Twitter or On Facebook

0 Comments for "Delete old log files in Linux"

What do you think about this Article? Add your Opinion..!

Back To Top