Solved

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

Posted on 2002-05-28
7
507 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now