Delete last 10 days logs


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Delete last 10 days logs
# 1  
Old 09-08-2008
MySQL Delete last 10 days logs

Hi

Can u please tell me how to delete last 10 days logs ..
# 2  
Old 09-08-2008
Code:
find . -type f -name "*.log" -mtime -10 -exec rm -f {} \;

If you want to keep last 10 days and delete everything older, write +10 instead of -10.

Best replace -exec .... by -print to see if it shows you the stuff you really want to delete.
# 3  
Old 09-08-2008
does the log text is put into one file or one file a day ?
# 4  
Old 09-08-2008
Thank u Zaxxon, its working fine..

find . -type f -name "*.log" -mtime+1 -print
if i use above command, its showing *.log files older than 3 days but it should give older than 1 day na...
# 5  
Old 09-08-2008
Actually it shows all files older than 1 day. So files older than 3 days are older than 1 day too.
# 6  
Old 09-08-2008
s ur right, but its showing the files older than 3days not showing older than 2 or 1st day files...
# 7  
Old 09-08-2008
it should give the files from older than 1 day ...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting 3 days old logs from a directory

As i am working in unix environment so i have an logs that is created by my application at the following location that is /opt/app/glac/current/servers/ops/logs inside the logs directory there are different kinds of logs(that is the file having extension as .log ) have been created... (1 Reply)
Discussion started by: 2015nks
1 Replies

2. Shell Programming and Scripting

Delete files 30 days old

Will this work to delete files 30 days old in $backupDir or is there a better way to do it? find $backupDir -type f -mtime +30 -exec rm {} \; (2 Replies)
Discussion started by: wyclef
2 Replies

3. Shell Programming and Scripting

Delete logs older than 60 days

i am using HP-UX OS...... delete logs older than 60 days find -mtime +60 | grep -i '.*log' | xargs rm -mtime is nt available in HP-UX, pls tell me other option ? (2 Replies)
Discussion started by: only4satish
2 Replies

4. Shell Programming and Scripting

[Solved] Fetching logs of last few days from logfile

Hi All, I have a requirement to fetch logs of last 'N' days. I am trying the following command which is working fine if it finds the date of that day in logfile. START=`TZ="GMT+$((24*N))" date +"%Y %b %d"` this is being used to fetch 'N'th day's date and awk '/'"$START"'/{p=1}... (24 Replies)
Discussion started by: KDMishra
24 Replies

5. Shell Programming and Scripting

To delete logs older than 30 days

I want to write a shell script that deletes all log files in a directory that are older than 30 days except for 3 files: I am using the following command: find /tmp/logs -name "*.log" -mtime +30 -exec rm -f {} \;But this command deletes all the log files. How can i modify this script that... (5 Replies)
Discussion started by: mmunir
5 Replies

6. Shell Programming and Scripting

How to remove the logs more than 5 days old

All, How to remove the logs that are more than 5 days old from a particular folder. Help will be highly appreciated. Regards Oracle User (2 Replies)
Discussion started by: Oracle_User
2 Replies

7. Shell Programming and Scripting

Delete a file after 3 days

Hi.. Am using diff to compare 2 directories(A & B) and as ouput i get a list of files which are found only in directory B ( I used grep & sed to create the list). Now I want to delete the files which are found only in dir B after 3 days. Please help me with this. Thanks CoolAtt (7 Replies)
Discussion started by: coolatt
7 Replies

8. UNIX for Advanced & Expert Users

how to archive logs older than 5 days & then delete them?

My code is tar -cvf logs.tar `find /usr/openv/logs/512*.log -mtime +2` && find *.log* -mtime +2 -exec rm {} \; this gives me output as: tar: Missing filenames:confused: (1 Reply)
Discussion started by: timus1980
1 Replies

9. Shell Programming and Scripting

Delete old logs

Hello All, We have a directory where we have old archived logs. They are numbered <logfile>.log.1 till <logfile>.log.100 or more. I just want to keep 10 log files and delete others through the script. Please advise. Thanks, Chiru (4 Replies)
Discussion started by: chiru_h
4 Replies

10. UNIX for Dummies Questions & Answers

How to delete files over 30 days

I have a directory that contains files. I would like the command that deletes all files that are over 30 days old. Delete files based on creation date and not modified. (2 Replies)
Discussion started by: GEBRAUN
2 Replies
Login or Register to Ask a Question