LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 03-26-2010, 05:58 AM   #1
RAFAL
Member
 
Registered: Feb 2006
Location: Warsaw, Poland
Distribution: openSUSE 11.4, openSUSE 12.3, SLES 11, Archlinux
Posts: 129

Rep: Reputation: 16
find and delete old files


Hi

I would like to delete some old redolog file in oracle directory and try this command:
Code:
find /oracle/IDS/oraarch -ctime +1 -print
Just to see a list (print, which I want to replace with delete)
I tried as well mtime and atime.
Unfortunately I get listed only 3 files (first 3 files), but the list should be much longer. I though maybe system time is wrong, but command 'date' gives me correct time. When I execute 'ls -la' I see whole list of files with dates.
I also tried to use 'stat <FILE>' to check some single files.
When I use:
Code:
find /oracle/IDS/oraarch -ctime 1 -print
the list is longer, but in this case I do not see older files

has anybody explanation for this strange behavior?

regards
Rafal

Last edited by RAFAL; 03-26-2010 at 06:01 AM. Reason: added one comment
 
Old 03-26-2010, 03:05 PM   #2
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 4&5, Fedora 10, CentOS 5.4, IPCop
Posts: 569

Rep: Reputation: 54
The time options of find are atime, ctime and mtime. These refer to, in order, the time the file was last accessed, the time the file's status was last changed, and the time the files data was last modified.

The option that most closely relates to the output of ls is mtime, so change your find statement to use that instead of ctime.
 
Old 03-29-2010, 04:55 AM   #3
RAFAL
Member
 
Registered: Feb 2006
Location: Warsaw, Poland
Distribution: openSUSE 11.4, openSUSE 12.3, SLES 11, Archlinux
Posts: 129

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by blacky_5251 View Post
The time options of find are atime, ctime and mtime. These refer to, in order, the time the file was last accessed, the time the file's status was last changed, and the time the files data was last modified.

The option that most closely relates to the output of ls is mtime, so change your find statement to use that instead of ctime.
hi

Thanks for the answer, but as I said "I tried as well mtime and atime."
its all the same, to I really do not know what is the issue here. Apparently something with "+" sign and the way how its interpreted

regards
Rafal
 
Old 03-29-2010, 05:57 AM   #4
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 4&5, Fedora 10, CentOS 5.4, IPCop
Posts: 569

Rep: Reputation: 54
Sorry for not reading properly. The difference between 1 and +1 is "exactly 1" compared to "more than 1" days ago. If you specify the "+" in your find, then it means "more than that many days" ago. If you leave it out, it means "exactly that many days ago".

An example from my server, using 32 instead of 1:-
Code:
[root@eddie WORK]# find . -mtime 32 -exec ls -ld {} \;
drwxrwsr-x 2 mhb crms 4096 Feb 25 17:43 ./at10528WRK
drwxrwsr-x 2 mhb crms 4096 Feb 25 17:45 ./at10735WRK
drwxrwsr-x 2 mhb crms 4096 Feb 25 17:43 ./at10573WRK
drwxrwsrwx 2 irb crms 4096 Feb 25 15:18 ./at1284WRK
drwxrwsr-x 2 mhb crms 4096 Feb 25 12:12 ./at21545WRK
drwxrwsrwx 2 irb crms 4096 Feb 25 15:20 ./at1902WRK
drwxrwsrwx 2 irb crms 4096 Feb 25 15:20 ./at1743WRK
drwxrwsrwx 2 irb crms 4096 Feb 25 15:20 ./at1856WRK
drwxrwsr-x 2 mhb crms 4096 Feb 25 17:30 ./at21605WRK
[root@eddie WORK]# find . -mtime +32 -exec ls -ld {} \;|grep "Feb 25"
[root@eddie WORK]#
Using "32" returns entries that are that many days old exactly, but using "+32" (and grepping only for Feb 25 to exclude all the other files it would return) doesn't return the same entries from Feb 25.

Plus, I still think you should use mtime instead of ctime

Last edited by blacky_5251; 03-29-2010 at 05:59 AM.
 
Old 03-30-2010, 03:59 AM   #5
RAFAL
Member
 
Registered: Feb 2006
Location: Warsaw, Poland
Distribution: openSUSE 11.4, openSUSE 12.3, SLES 11, Archlinux
Posts: 129

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by blacky_5251 View Post
find . -mtime +32 -exec ls -ld {} \;|grep "Feb 25"
I tried again and now worked fine.
Thanks a lot for your help
I don't understand why it didn't worked before, but the main thing is : it works now

regards
Rafal
 
  


Reply

Tags
bash, find, mtime


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Find and delete string in text files damgar Linux - Software 3 03-06-2010 09:27 PM
Delete files script using Find and Tar Zypher123 Red Hat 1 12-12-2008 09:45 AM
Using find and rm command to delete files over x days old 200mg Linux - Newbie 16 09-03-2008 06:41 PM
fast easy way to find old files to delete??? lowlight1177 Linux - Software 2 04-06-2006 07:35 PM
find and delete files - stupid question though smshuja Linux - Newbie 5 12-29-2005 01:21 AM


All times are GMT -5. The time now is 10:38 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration