RE: mtime removing exports Linux

From: Herring Dave - dherri <Dave.Herring_at_acxiom.com>
Date: Mon, 22 Aug 2011 13:18:09 +0000
Message-ID: <BD475CE0B3EE894DA0CAB36CE2F7DEB42044C191_at_LITIGMBCRP02.Corp.Acxiom.net>



Have you checked "ls -ltr" on this directory to make sure other files are indeed dated more than 24 hrs beyond the time this command ran? You may want to include that in your script so you can validate what's going on.

But if you only want the most recent copy, you could use:

        % ls -1 $EXPORT_DIR | grep -v "`ls -ltr $EXPORT_DIR | tail -1 | awk '{print $9}'`" | xargs -i rm {}

That says for all files in $EXPORT_DIR, remove all except the most recent one.

DAVID HERRING
DBA
Acxiom Corporation

EML   dave.herring_at_acxiom.com
TEL    630.944.4762
MBL   630.430.5988 

1501 Opus Pl, Downers Grove, IL 60515, USA WWW.ACXIOM.COM

The information contained in this communication is confidential, is intended only for the use of the recipient named above, and may be legally privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please resend this communication to the sender and delete the original message or any copy of it from your computer system. Thank you.

From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of P D Sent: Monday, August 22, 2011 8:01 AM
To: oracle-l_at_freelists.org
Subject: mtime removing exports Linux

I only want to keep one copy of an export on the server.   I have got this in a script on a Linux RHEL5 server.   It saves 3 days though instead of 1 and even if I put mtime 0 it still saves more than one.    What is wrong with it?    
find $EXPORT_DIR -name "*" -mtime +1 -exec rm -rf {} \; > /dev/null

--
http://www.freelists.org/webpage/oracle-l
Received on Mon Aug 22 2011 - 08:18:09 CDT

Original text of this message