🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #19294

Re: Identifying stale news groups?

#19294
From: Jeff Garzik
Date: Tue, 15 Jul 1997 00:00
101 lines
3365 bytes
This is a multi-part message in MIME format.

--------------DB3D9B31138DDE33F642CAB
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

(copy cc'd to author)

Brian Murrell wrote:
> I seem to recall that INN creates directories for
> newsgroups if they are not there.  Am I recalling that correctly?


Yep.  I use this script to keep my spool clean.  I run a fairly unique
expiration policy, where my default policy is

	*:A:0.2:0.2:0.2

...and then I un-specify hierarchies that are actually read.  This lends
itself to a lot of empty directories.  I run the script once a week
(along with fixhist, find-missing.pl, and the other INN janitors) to
remove junk like the sexzilla groups, which get newgrouped, then never
get any posts except spam.
-- 
Jeff Garzik					   Quality news feeds
News Administrator		       INN Technical info, Consulting
Spinne, Inc.				http://www.spinne.com/usenet/

--------------DB3D9B31138DDE33F642CAB
Content-Type: text/plain; charset=us-ascii; name="remove-empty-dirs.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="remove-empty-dirs.pl"

#!/usr/local/bin/perl
#
# find-empty-dirs -- find empty news spool directories and remove em
#
# Jeff Garzik <jgarzik@pobox.com>
#

$SpoolDir = '/var/news/spool/articles';

$start_time = time;
$removed = 0;

&remove_empty($SpoolDir);
$elapsed = time - $start_time;
print "find-empty-dirs: $removed dirs removed, $elapsed seconds\n";
exit(0);

sub numerically { return $a <=> $b; }

sub remove_empty {
  my ($dir) = @_;
  my (@files, $fn, @pos, $i);

  # DEBUG statement
  # print "DIR: $dir\n";

  if (!opendir(DIR, $dir)) {
    print STDERR "Cannot open $dir: $!\n";
    return 0;
  }
  @files = readdir(DIR);
  close(DIR);

  return 1 if (($#files == 1) &&
               (($files[0] eq ".") || ($files[0] eq "..")) &&
               (($files[1] eq ".") || ($files[1] eq "..")));

  foreach $i (0 .. $#files) {
    next if ($files[$i] =~ /^\d+$/);
    next if ($files[$i] =~ /\./);

    if ((-d "$dir/" . $files[$i]) && (&remove_empty("$dir/" . $files[$i]))) {
      if (rmdir("$dir/" . $files[$i])) {
        $removed++;
        print "REMOVED: $dir/", $files[$i], "\n";
        push(@pos, $i);
      } else {
        print STDERR "Cannot remove $dir: $!\n";
      }
    }
  }

  foreach $i (reverse sort numerically @pos) {
    splice(@files, $i, 1);
  }

  return 1 if (($#files == 1) &&
               (($files[0] eq ".") || ($files[0] eq "..")) &&
               (($files[1] eq ".") || ($files[1] eq "..")));

  return 0;
}

--------------DB3D9B31138DDE33F642CAB--


Technical Details
Message-ID: <33CC0FB6.7F36CFE1@spinne.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <33AEC260.292@bctel.net> <Pine.LNX.3.96.970623215015.27718H-100000@marley.vszbr.cz> <33B00766.5208@bctel.net>

Show Full Headers
Complete Article Headers
Message-ID: <33CC0FB6.7F36CFE1@spinne.com>
Subject: Re: Identifying stale news groups?
Date: Tue, 15 Jul 1997 00:00:00 +0000
From: Jeff Garzik <jeff.garzik@spinne.com>
References: <33AEC260.292@bctel.net> <Pine.LNX.3.96.970623215015.27718H-100000@marley.vszbr.cz> <33B00766.5208@bctel.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 257091346
To: Brian Murrell <brian_murrell@bctel.net>
Organization: Spinne http://spinne.com
Newsgroups: news.software.nntp