Skip to content
Snippets Groups Projects
Commit ec6f3c17 authored by taggart's avatar taggart
Browse files

new script to find the oldest lists we host

parent bccb2280
Branches
No related tags found
No related merge requests found
#!/usr/bin/perl -w
# oldestlists - list the oldest lists
# NOTE: this script requires the current user has read access to the db
# Matt Taggart <taggart@riseup.net> 2019-11
use POSIX;
$num=100;
$i=0;
$expl='/home/sympa/expl';
# get a list of all lists in the db
$listsql='mysql -N --batch --database=sympa --execute "select name_list from list_table where status_list = \'open\'"';
open(LISTDUMP, "$listsql|") or die "cannot get dump of lists from database\n";
while (<LISTDUMP>) {
chomp;
$list=$_;
$dates=`grep date_epoch $expl/$list/config |awk '{print \$2}'`;
my ($a,$b) = split /\n/, $dates;
# sometimes a config doesn't have a creation date, skip
next if ( $b eq '') ;
# creation date will be older (smaller)
if ( $a > $b ) {
$result{$list}=$b;
} else {
$result{$list}=$a;
}
}
format Foo =
@<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$date, $list
.
$~=Foo;
$date='Date';
$list='List Name';
write;
foreach $list ( sort { $result{$a} <=> $result{$b} } keys %result ) {
$i++;
last if ( $i > $num );
$date = strftime "%Y %b %e", localtime($result{$list});
write;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment