LinuxQuestions.org
Review your favorite Linux distribution.
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 11-03-2007, 08:22 AM   #1
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Rep: Reputation: 30
delete old files


Dear All,

I have a partition which is 90% filled.. I want to keep one month files in that disk and delete all the old files.. how do I acheive this ?



output of ls -rlt like this :


rw-r----- 1 oraprod dba 10484224 Nov 3 10:05 prod_arch_5556.arc
-rw-r----- 1 oraprod dba 10484224 Nov 3 10:24 prod_arch_5557.arc
-rw-r----- 1 oraprod dba 10484224 Nov 3 10:40 prod_arch_5558.arc
-rw-r----- 1 oraprod dba 10484224 Nov 3 10:58 prod_arch_5559.arc
-rw-r----- 1 oraprod dba 10484224 Nov 3 11:15 prod_arch_5560.arc
-rw-r----- 1 oraprod dba 10484224 Nov 3 11:34 prod_arch_5561.arc
-rw-r----- 1 oraprod dba 10484224 Nov 3 11:54 prod_arch_5562.arc
-rw-r----- 1 oraprod dba 10484224 Nov 3 12:13 prod_arch_5563.arc
-rw-r----- 1 oraprod dba 10484224 Nov 3 12:32 prod_arch_5564.arc


Please guide me


Thanks
Yusuf
 
Old 11-03-2007, 08:43 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
If this is a directory that contains files that can be removed after a certain time, and there are no subdirectories where files must be kept.

you could try:
Code:
find /path/to/directory -type f -mtime +31|xargs ls -l
If you are sure this lists only files that you want to delete:
Code:
find /path/to/directory -type f -mtime +31|xargs rm -f
If you leave out the xargs then you will not get the correct result.
the ls -l would show the contents of the current directory, and the rm command would not remove any files.
 
Old 11-04-2007, 01:45 AM   #3
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
thanks disillusionist.. but..

Quote:
Originally Posted by Disillusionist View Post
If this is a directory that contains files that can be removed after a certain time, and there are no subdirectories where files must be kept.

you could try:
Code:
find /path/to/directory -type f -mtime +31|xargs ls -l
If you are sure this lists only files that you want to delete:
Code:
find /path/to/directory -type f -mtime +31|xargs rm -f
If you leave out the xargs then you will not get the correct result.
the ls -l would show the contents of the current directory, and the rm command would not remove any files.
Hai,

Thanks for your answer.. but..

[oraprod@alioracle prodarch]$ find /d03/oraprod/prodarch -type f -mtime +31|xargs ls -l | wc -l

2819


the above is 100% ok,,

but whereas when I try to delete the files,am getting error like :

[oraprod@alioracle prodarch]$ find /d03/oraprod/prodarch -type f -mtime +31|xargs ls -l | rm -rf
xargs: ls: terminated by signal 13


Please guide me..


Thanks in advance
Yusuf
 
Old 11-04-2007, 02:23 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681
Don't have the "ls" command in the pipe.
Code:
find /d03/oraprod/prodarch -type f -mtime +31 |xargs rm -rf

Last edited by jschiwal; 11-04-2007 at 02:24 AM.
 
Old 11-04-2007, 02:35 AM   #5
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
thanks .. it is working fine..

Quote:
Originally Posted by jschiwal View Post
Don't have the "ls" command in the pipe.
Code:
find /d03/oraprod/prodarch -type f -mtime +31 |xargs rm -rf

Thanks a lot disillunioist and jschiwal for your kind answers.. I fixed it using your help.. this forum is really helping newbies like me..


thanks
Yusuf
 
Old 11-04-2007, 04:46 AM   #6
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
Yusufs

This looks like you are removing oracle archive file.

If this is the case, you must run an RMAN crosscheck before the next backup otherwise the backup will fail!
 
Old 11-05-2007, 01:22 AM   #7
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Rman

Quote:
Originally Posted by Disillusionist View Post
Yusufs

This looks like you are removing oracle archive file.

If this is the case, you must run an RMAN crosscheck before the next backup otherwise the backup will fail!


Thanks Disilluionist for your comments.. anyway we are not taking hotbackup.. we can managed to take full cold backup and we are not using rman..


Thanks for your patience and ideas
Yusuf
 
Old 11-05-2007, 01:50 AM   #8
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
If you are not taking hot backups why have the database in archive log mode?

If the archive area runs out of space the database will not perform any updates until space is created.

If your cold backup kicks in at this point, it will be unable to shutdown the database cleanly and therefore you would be backing up open database files which will leave the database unrecoverable.
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete files that won't delete? di11rod Linux - Security 7 10-19-2005 09:14 PM
Delete Files imsajjadali Red Hat 15 07-23-2004 01:12 PM
How to delete the destination files while the source files deleted in cp -u ? myunicom Linux - General 4 09-26-2003 01:13 PM
Can't delete some files... Tomcat_cdm Linux - Newbie 2 03-11-2003 10:26 PM
Delete Files bsengland Linux - Newbie 1 11-04-2002 05:29 PM

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

All times are GMT -5. The time now is 11:43 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