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
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 {} \;
find /var/log/ -name *.log -mtime +10 -exec ls -tl {} \;
find /var/log/ -name *.log -mtime +10 -exec rm -f {} \;
What do you think about this Article? Add your Opinion..! EmoticonEmoticon