Removing Old log files from Linux


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Removing Old log files from Linux
# 1  
Old 02-04-2013
Removing Old log files from Linux

Dear Friends,

I want to remove the 10 days old log files from paticular directory. I want to use some other command for removing the old log files other than find command. Because in our system find command is taking too much of time to remove the old files.
Kindly give me the solution for this issue.
# 2  
Old 02-04-2013
That your find command is taking so long means you've either let it search too widely, or you have a real messy and full directory structure that can't be sped up.

Hoping it's the former, please show us your slow find command and some examples of files in locations you want it to remove.
# 3  
Old 02-06-2013
The alternative is locate. But find implements it's own expression syntax because it provides a richer set of filter and action options. There's no alternative that can do the same, simply because it would be redundant.
but on find ,
you can try this out

Code:
find /your/directory/*.log -type f -mtime +10 -exec rm -r{} \;


Last edited by charli1; 02-06-2013 at 11:11 AM..
# 4  
Old 02-06-2013
Quote:
Originally Posted by charli1
you can try this out

Code:
find /your/directory/*.log -type f -mtime +10 -exec rm -r{} \;

Right, but with a small correction:
Code:
find /your/directory/ -name \*.log -type f -mtime +10 -exec rm {} \;

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Single line archive log files command if exceed certain limit in Linux

Hello Guys, Is there a single line archive command to zip or tar log files which is larger than certain size limit ? Do let me know if there is any. Thanks (7 Replies)
Discussion started by: UnknownGuy
7 Replies

2. UNIX for Beginners Questions & Answers

Find and removing the old files and zipping the files using shell script

Hi, I am trying to removing the old files which were older than 10 days and same g zipping the files using the shell script. script was return as follows. find /jboss7_homes/JBOSS7/SKYLIV??/SKYLIV??_CRM/jboss-eap-7.0/standalone/log -mtime +10 -type f | xargs rm -f find /cer_skyliv??/log... (6 Replies)
Discussion started by: venkat918
6 Replies

3. UNIX for Dummies Questions & Answers

Removing ^@ chanracter fromthe end of Linux file

Hi, I have a Linux file which has content as shown below 2,Latest Event in RFP_EVENT match Lastest event in Source PRH_RQ_REQUEST,Failed... (3 Replies)
Discussion started by: bhuvanas
3 Replies

4. UNIX for Dummies Questions & Answers

Removing ^@ character at the end own belowof Linux file

Hi, I have a Linux file which has content as sh (0 Replies)
Discussion started by: bhuvanas
0 Replies

5. Shell Programming and Scripting

parsing log files, removing spaces and replace with commas

Hello all i am working on a database to import log files from my systems, but i cannot seem to find the answer. I searched here for a good bit and couldnt peice together what i was looking for. I know you could do this with awk, i just dont know how. Any help would be greatly appreciated.... (6 Replies)
Discussion started by: caddyjoe77
6 Replies

6. Shell Programming and Scripting

removing old files except configuration files and folders

Dear all, I want to remove files older than 2 months in the /home/member directory. But except the configuration files (like .bash_profile .config/ .openoffice/ .local/ .kde/ etc..) I have tried with the command find . -mtime +60 -wholename './.*' -prune -o -print -exec mv {} \; but it... (1 Reply)
Discussion started by: jamcalicut
1 Replies

7. UNIX for Dummies Questions & Answers

removing files

Hello all, I'd like to remove files which is returned by the following statement ls -l arch*.dbf|grep "`date|cut -c5-10`" (cut -c5-10 =Mar 20) To achive this,I tried the following statments but none worked .. rm < `ls -l arch*.dbf|grep "`date|cut -c5-10`"` rm `ls -l arch*.dbf|grep... (8 Replies)
Discussion started by: luft
8 Replies

8. UNIX for Dummies Questions & Answers

removing linux/extra partition??

ok, well i never could get my internet connection setup in linux so now it is just wasting space on my system... so, how do i get rid of it and the extra partition made during install?? (1 Reply)
Discussion started by: justchillin
1 Replies

9. UNIX for Dummies Questions & Answers

Removing Files

I am trying to remove a file so that I can delete a directory. Unfortuantely the file looks like this --------.--- and the system is not allowing me to remove the file. System message is rm: Error: Illegal option -- - usage: rm file... I have tried rm * and rm *.* to no avail. Any... (5 Replies)
Discussion started by: Blondie
5 Replies
Login or Register to Ask a Question