Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site fortune.UUCP
Path: utzoo!watmath!clyde!cbosgd!ihnp4!fortune!stein
From: stein@fortune.UUCP (Mark Stein)
Newsgroups: net.news.b
Subject: Re: files left in /tmp & spool.
Message-ID: <4767@fortune.UUCP>
Date: Tue, 11-Dec-84 17:35:50 EST
Article-I.D.: fortune.4767
Posted: Tue Dec 11 17:35:50 1984
Date-Received: Wed, 12-Dec-84 06:13:16 EST
References: <2500001@ciprico.UUCP>
Organization: Fortune Systems, Redwood City, CA
Lines: 67

> I'm having a little problem here...it's with news leaving lots of
> "L
#include 
#include 
#include 

#define SPOOL	"/usr/spool/news"		/* directory to open */
#define AGE	60*60*24*7			/* 7 days of seconds */

main(argc, argv)
int argc;
char *argv[];
{
	DIR *dirp;				/* directory ptr */
	struct direct *de;			/* directory entry */
	struct stat sbuf;			/* stat info */
	char path[100];				/* buf for pathname */
	long age = AGE;				/* aging time */
	long now, time();;			/* time right now */

	now = time(0);
	if ((dirp = opendir(SPOOL)) == NULL) {
		perror(SPOOL);
		exit(1);
	}
	if (argc > 1)
		age = atoi(argv[1]);
	while (de = readdir(dirp)) {
		if(   (de->d_namlen == 9 && (   !strncmp(de->d_name, ".ar", 3)
					     || !strncmp(de->d_name, ".in", 3)))
		   || (de->d_namlen == 8 &&     !strncmp(de->d_name, "tr",  2)))
		{
			sprintf(path, "%s/%s", SPOOL, de->d_name);
			if (stat(path, &sbuf) < 0) {
				perror(path);
				continue;
			}
			if (now - sbuf.st_mtime > age)
				unlink(path);
		}
	}
}