Solved

find and remove old files (include 2G and up sizes)

Posted on 2002-05-28
7
511 Views
Last Modified: 2013-11-18
our old command :
find . -mtime +1 -exec rm -rf {} \;
doesn't work with files larger>2GB under RedHat Linux 7.1

example :
13:34{320}lnx16:tmp_dumps> ls -lR
...
...
-rw-r--r--    1 yanivb   ftp      3973090008 May 26 15:44 ncsim.trn

But with find on the same location :

We can see that find gives files < 2GB :


13:34{315}lnx16:fox> find . -mtime +1 -exec ls -l {} \;
total 1969300
-rw-r--r--    1 evgeny   ftp      17220328 May 26 13:05 ncsim.dsn
-rw-r--r--    1 evgeny   ftp      1997353600 May 26 13:05 ncsim.trn
-rw-r--r--    1 evgeny   ftp      17220328 May 26 13:05 ./ncsim.shm.2_6_3.evgeny.26May/ncsim.dsn
-rw-r--r--    1 evgeny   ftp      1997353600 May 26 13:05 ./ncsim.shm.2_6_3.evgeny.26May/ncsim.trn

the problem : how to remove them all , regardless size ???
0
Comment
Question by:Talmash
  • 3
  • 3
7 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7039300
probably your RH cannot handle files ith size > 2GB, this is a kernel limitation.
To remove such files you either need a kernel with large-file support (AFAIK 2.4.x), or use debugfs for these files.
0
 
LVL 6

Author Comment

by:Talmash
ID: 7041124
my old dear friend hoffmann !

what is debugfs ?

FYI , this question I forward to our company's system admin. ,
I suggested to him , to solve our problem using a script :

1) ls -lR > list
2) foreach i (list)
          look for files older then 24 hours and remove them .
(the filtering will using a script to read the Month and Day from the ls -l output , example :

ls -l :
-rw-r--r--   1 talm        38912 Apr 15 13:39 HotInit_LinkList_2k.txt
file date = num(Apr)+(15)/100 = 4.15
date = num(May)+(29)/100 = 5.29
if (date - file_date > 0.01)
     rm file

(this script got problem with January/December can be solved with seperated IF condition (file_date > 12 && data < file_date && date < 2)

0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 total points
ID: 7041244
> what is debugfs ?
following stolen from  man debugfs:

NAME
   debugfs - ext2 file system debugger

SYNOPSIS
   debugfs [-f cmd_file] [-R request] [-V] [-w [device]]

DESCRIPTION
   The debugfs program is a file system debugger. It can be
   used to examine and change the state of an ext2 file system.
   device is the special file  corresponding to the device
   containing the ext2 file system (e.g /dev/hdXX).
...


Waht has you "check file date" script to do with the 2GB file problem?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 6

Author Comment

by:Talmash
ID: 7041309
tnx hof ,

the script will "find" files older then 24 hours using the ls -l , NOT using the 'find' command .

the script will decide how old is the file up to the Month/Day (from ls -l) and rm it .

I forwarded your comment to our sys.admin.

waiting for a response from him .

tal
0
 
LVL 20

Expert Comment

by:tfewster
ID: 7921246
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- PAQ & refund points

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster
Cleanup Volunteer
0
 
LVL 6

Author Comment

by:Talmash
ID: 7923590
since I know you long time ,
and since u r the only respondant ,

get my points , although I was aaking to a script .

from time to time , I meet such problems .
some I solve by myself , and some I forward to other hope
he will solve .

I wished to get the solution from you .

anyway , this specific case , my idea was found good to our sysadmin , and he changed the auto-script to replace 'find' with smarter search .

Tal
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7924163
hmm, didn't recognize the "script request", sorry. But AFAIK debugfs cannot be scripted, you need expect for that.
Thanks anyway for cleaning up this qeustion.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question