LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   delete old files (https://www.linuxquestions.org/questions/linux-newbie-8/delete-old-files-596834/)

yusufs 11-03-2007 08:22 AM

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

Disillusionist 11-03-2007 08:43 AM

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.

yusufs 11-04-2007 01:45 AM

thanks disillusionist.. but..
 
Quote:

Originally Posted by Disillusionist (Post 2946774)
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

jschiwal 11-04-2007 02:23 AM

Don't have the "ls" command in the pipe.
Code:

find /d03/oraprod/prodarch -type f -mtime +31 |xargs rm -rf

yusufs 11-04-2007 02:35 AM

thanks .. it is working fine..
 
Quote:

Originally Posted by jschiwal (Post 2947564)
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

Disillusionist 11-04-2007 04:46 AM

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!

yusufs 11-05-2007 01:22 AM

Rman
 
Quote:

Originally Posted by Disillusionist (Post 2947632)
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

Disillusionist 11-05-2007 01:50 AM

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.


All times are GMT -5. The time now is 01:54 AM.