RE: [SLE] Howto delet file automaticly base on periode.
this script does approx what you want: it deletes files in a directory and all directories below, older than so many days: works for me. cheers, mj #!/usr/bin/perl -w use strict; use Getopt::Std; use File::Find; @ARGV > 0 and getopts('a:', \my %opt) or die << "USAGE"; Deletes any old files from the directory tree(s) given and removes empty directories en passant. usage: $0 [-a maxage] directory [directory ...] -a maximum age in days, default is 7 USAGE my $max_age_days = $opt{a} || 7; find({ wanted => sub { unlink if -f $_ and -M _ > $max_age_days }, postprocess => sub { rmdir $File::Find::dir }, }, @ARGV);
-----Original Message----- From: James Knott [mailto:james.knott@rogers.com] Sent: 27 April 2005 13:01 To: suse-linux-e@suse.com Subject: Re: [SLE] Howto delet file automaticly base on periode.
Arie Reynaldi Z wrote:
Hi all,
I have made a script for backup purpose, so it will backup my folder daily and creates files like this : -rw-r--r-- 1 root root 97751911 Apr 25 17:27 stock-25-Apr-2005_17-25-33.tgz -rw-r--r-- 1 root root 97754710 Apr 26 17:11 stock-26-Apr-2005_17-00-00.tgz
Then after certain period, like weekly or monthly, I want to delete the oldest file. Now, how can I make a script to do that job ? I know the crontab can do it, but how can I remove just the oldest file automaticly, not whole file or directory ?
In a script, simply have a list of copy instructions such as cp ver9 ver10 cp ver8 ver9 . . . cp ver1 ver2
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
participants (1)
-
mourik jan heupink