LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-31-2011, 06:06 AM   #1
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Rep: Reputation: 148Reputation: 148
find one day older files


I used following command to sort one day older log files
Quote:
find /opt/TimesTen/tt_transaction_log/ -name "mtsDB.log*" -mtime +1 -print
following are log files which are existing, I have to delete one day older files from this location but when use above mentioned command it won't print one day older files, as i understand "-mtime" modified time, "+1" means one day older. am i correct?
Code:
-rw-rw-rw-   1 ablddb   dba      268435456 May 30 17:11 mtsDB.log126985
-rw-rw-rw-   1 ablddb   dba      268435456 May 30 17:17 mtsDB.log126986
-rw-rw-rw-   1 ablddb   dba      268435456 May 30 17:23 mtsDB.log126987
-rw-rw-rw-   1 ablddb   dba      268435456 May 30 17:29 mtsDB.log126988
...
...
...
-rw-rw-rw-   1 ablddb   dba      268435456 May 31 18:41 mtsDB.log127151
-rw-rw-rw-   1 ablddb   dba      268435456 May 31 18:47 mtsDB.log127152
-rw-rw-rw-   1 ablddb   dba      268435456 May 31 18:53 mtsDB.log127153
-rw-rw-rw-   1 ablddb   dba      152846336 May 31 18:57 mtsDB.log127154
How can i print one day older logfiles?

Last edited by kirukan; 05-31-2011 at 06:08 AM.
 
Old 05-31-2011, 06:16 AM   #2
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
normally it should work!
i can't seem to find a problem here, because i use the same sort of code (for other purposes) and it works fine by me?!
 
Old 05-31-2011, 08:07 AM   #3
Adol
Member
 
Registered: Feb 2011
Location: Osaka, Japan
Distribution: Gentoo, Opensuse
Posts: 271

Rep: Reputation: 6
here is a command that I use:
Code:
find /home/petreuss/test/ -iname "*" -mtime -30 -print0 | xargs -0 -I {} cp -v {} /home/petreuss/test2/
The main difference of the find command is that I use
Code:
-iname
you use
Code:
-name
Not sure but could that be the problem?

you can change the xargs options to copy, remove, move or any other command. Mine is set to copy.

Here is how mtime works:

Code:
find . -mtime 0 # find files modified between now and 1 day ago
# (i.e., within the past 24 hours)
find . -mtime -1 # find files modified less than 1 day ago
# (i.e., within the past 24 hours, as before)
find . -mtime 1 # find files modified between 24 and 48 hours ago
find . -mtime +1 # find files modified more than 48 hours ago

find . -mmin +5 -mmin -10 # find files modified between
# 6 and 9 minutes ago
are you getting an error message or is it just not finding the correct files?
 
Old 05-31-2011, 10:37 PM   #4
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Original Poster
Rep: Reputation: 148Reputation: 148
#ls -l
Code:
-rw-rw-rw-   1 ablddb   dba      268435456 May 30 17:11 mtsDB.log126985
-rw-rw-rw-   1 ablddb   dba      268435456 May 30 17:17 mtsDB.log126986
-rw-rw-rw-   1 ablddb   dba      268435456 May 30 17:23 mtsDB.log126987
-rw-rw-rw-   1 ablddb   dba      268435456 May 30 17:29 mtsDB.log126988
...
...
-rw-rw-rw-   1 ablddb   dba      268435456 May 31 11:13 mtsDB.log127082
-rw-rw-rw-   1 ablddb   dba      268435456 May 31 11:20 mtsDB.log127083
-rw-rw-rw-   1 ablddb   dba      268435456 May 31 11:27 mtsDB.log127084
....
-rw-rw-rw-   1 ablddb   dba      268435456 Jun  1 11:13 mtsDB.log127233
-rw-rw-rw-   1 ablddb   dba      268435456 Jun  1 11:20 mtsDB.log127234
-rw-rw-rw-   1 ablddb   dba      31539200 Jun  1 11:21 mtsDB.log127235
find /opt/TimesTen/tt_transaction_log/ -name "mtsDB.log*" -mtime +0 -print
Code:
/opt/TimesTen/tt_transaction_log/mtsDB.log126987
/opt/TimesTen/tt_transaction_log/mtsDB.log126988
/opt/TimesTen/tt_transaction_log/mtsDB.log126989
...
....
/opt/TimesTen/tt_transaction_log/mtsDB.log127082
/opt/TimesTen/tt_transaction_log/mtsDB.log127083
command executed time
Code:
Wed Jun  1 11:21:33 SGT 2011
Exactly "-mtime +0" retrieve 24hours older files but it skips following two files
Code:
-rw-rw-rw-   1 ablddb   dba      268435456 May 30 17:11 mtsDB.log126985
-rw-rw-rw-   1 ablddb   dba      268435456 May 30 17:17 mtsDB.log126986
Any guess?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto find files with ctime older than X seconds? spangberg Linux - General 2 06-05-2013 05:23 AM
[SOLVED] Delete regular files (not hidden files) with find + rm in one line older than 15 Virtuose Linux - Newbie 1 01-08-2011 05:24 PM
Script help - delete files older than 45 days but exclude the system files jojothedogboy Linux - Software 3 06-13-2008 03:43 PM
Deleting Files Older Than 2 Hours using Find? LinuxGeek Linux - Software 1 06-29-2005 06:10 AM
find files older than another file bmeckle Linux - Software 2 10-21-2004 10:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration