From owner-freebsd-current Thu Feb 5 16:00:27 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id QAA28666 for current-outgoing; Thu, 5 Feb 1998 16:00:27 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from smtp04.primenet.com (smtp04.primenet.com [206.165.6.134]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id QAA28624 for ; Thu, 5 Feb 1998 16:00:24 -0800 (PST) (envelope-from tlambert@usr09.primenet.com) Received: (from daemon@localhost) by smtp04.primenet.com (8.8.8/8.8.8) id RAA25564 for ; Thu, 5 Feb 1998 17:00:23 -0700 (MST) Received: from usr09.primenet.com(206.165.6.209) via SMTP by smtp04.primenet.com, id smtpd025521; Thu Feb 5 17:00:15 1998 Received: (from tlambert@localhost) by usr09.primenet.com (8.8.5/8.8.5) id RAA27563 for current@freebsd.org; Thu, 5 Feb 1998 17:00:12 -0700 (MST) From: Terry Lambert Message-Id: <199802060000.RAA27563@usr09.primenet.com> Subject: PATCH: new option for newsyslog To: current@FreeBSD.ORG Date: Fri, 6 Feb 1998 00:00:12 +0000 (GMT) X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG X-To-Unsubscribe: mail to majordomo@FreeBSD.org "unsubscribe current" When debugging problems that show up in the logs, it's useful to be able to zero the logs. But you don't want to lose the existing log data, you just want to start over with a clean slate. I have added a "-F" option ("Force") to newsyslog to force it to rotate the logs, even if the rotation criteria have not been met. Here are the (trivial) patches to the program itself and to the man page for the program. Please commit these... PS: still waiting for a "Bcc:" option for send-pr so I can Cc: a copy of these bug reports to send-pr... Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. --------------------------------------------------------------------------- Index: newsyslog.8 =================================================================== RCS file: /cvs/freebsd/src/usr.sbin/newsyslog/newsyslog.8,v retrieving revision 1.9 diff -c -r1.9 newsyslog.8 *** newsyslog.8 1997/10/06 07:46:06 1.9 --- newsyslog.8 1998/02/05 23:30:44 *************** *** 152,157 **** --- 152,163 ---- will not be able to send a HUP signal to .Xr syslogd 8 so this option should only be used in debugging. + .It Fl F + Force + .Nm + to trim the logs, even if the trim conditions have not been met. This + option is useful for diagnosing system problems by providing you with + fresh logs that contain only the problems. .El .Sh FILES .Bl -tag -width /etc/newsyslog.confxxxx -compact Index: newsyslog.c =================================================================== RCS file: /cvs/freebsd/src/usr.sbin/newsyslog/newsyslog.c,v retrieving revision 1.15 diff -c -r1.15 newsyslog.c *** newsyslog.c 1997/11/30 18:58:18 1.15 --- newsyslog.c 1998/02/05 23:30:44 *************** *** 89,94 **** --- 89,95 ---- int verbose = 0; /* Print out what's going on */ int needroot = 1; /* Root privs are necessary */ int noaction = 0; /* Don't do anything, just show it */ + int force = 0; /* Force the tim no matter what*/ char *conf = CONF; /* Configuration file to use */ time_t timenow; pid_t syslog_pid; /* read in from /etc/syslog.pid */ *************** *** 159,165 **** printf("size (Kb): %d [%d] ", size, ent->size); if (verbose && (ent->hours > 0)) printf(" age (hr): %d [%d] ", modtime, ent->hours); ! if (((ent->size > 0) && (size >= ent->size)) || ((ent->hours > 0) && ((modtime >= ent->hours) || (modtime < 0)))) { if (verbose) --- 160,167 ---- printf("size (Kb): %d [%d] ", size, ent->size); if (verbose && (ent->hours > 0)) printf(" age (hr): %d [%d] ", modtime, ent->hours); ! if (force || ! ((ent->size > 0) && (size >= ent->size)) || ((ent->hours > 0) && ((modtime >= ent->hours) || (modtime < 0)))) { if (verbose) *************** *** 201,207 **** } optind = 1; /* Start options parsing */ ! while ((c=getopt(argc,argv,"nrvf:t:")) != -1) switch (c) { case 'n': noaction++; /* This implies needroot as off */ --- 203,209 ---- } optind = 1; /* Start options parsing */ ! while ((c=getopt(argc,argv,"nrvFf:t:")) != -1) switch (c) { case 'n': noaction++; /* This implies needroot as off */ *************** *** 215,220 **** --- 217,225 ---- case 'f': conf = optarg; break; + case 'F': + force = 1; + break; default: usage(); } ---------------------------------------------------------------------------