Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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

Posted on 2002-05-28
Medium Priority
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 ???
Question by:Talmash
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 51

Expert Comment

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.

Author Comment

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)

LVL 51

Accepted Solution

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

   debugfs - ext2 file system debugger

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

   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?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

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 .

LVL 21

Expert Comment

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


Cleanup Volunteer

Author Comment

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 .

LVL 51

Expert Comment

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.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

670 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