View | Details | Raw Unified | Return to bug 29363 | Differences between
and this patch

Collapse All | Expand All

(-)newsyslog.8 (+9 lines)
Lines 28-33 Link Here
28
.Op Fl Fnrv
28
.Op Fl Fnrv
29
.Op Fl f Ar config_file
29
.Op Fl f Ar config_file
30
.Op Fl a Ar directory
30
.Op Fl a Ar directory
31
.Op Fl T Ar timeformat
31
.Op Ar
32
.Op Ar
32
.Sh DESCRIPTION
33
.Sh DESCRIPTION
33
.Nm Newsyslog
34
.Nm Newsyslog
Lines 354-359 Link Here
354
to trim the logs, even if the trim conditions have not been met.  This
355
to trim the logs, even if the trim conditions have not been met.  This
355
option is useful for diagnosing system problems by providing you with
356
option is useful for diagnosing system problems by providing you with
356
fresh logs that contain only the problems.
357
fresh logs that contain only the problems.
358
.It Fl T
359
Time based extension
360
.Nm
361
to rename all logs that get trimmed into with an extension based on the
362
argument given by this option. This option can be any strfime(3) string.
363
 This function is intended for permantely storing of logfiles.  If the
364
patten results to an already existing file, operations breaks without
365
cleanup, leaving stale logs in place, that might be ovewritten.
357
.El
366
.El
358
.Pp
367
.Pp
359
If additional command line arguments are given,
368
If additional command line arguments are given,
(-)newsyslog.c (-17 / +26 lines)
Lines 90-96 Link Here
90
int needroot = 1;		/* Root privs are necessary */
90
int needroot = 1;		/* Root privs are necessary */
91
int noaction = 0;		/* Don't do anything, just show it */
91
int noaction = 0;		/* Don't do anything, just show it */
92
int force = 0;			/* Force the trim no matter what */
92
int force = 0;			/* Force the trim no matter what */
93
char *archdirname;		/* Directory path to old logfiles archive */
93
int timename = 0;		/* Use time of rotation as suffix */
94
const char *archdirname;	/* Directory path to old logfiles archive */
95
const char *timearg;		/* Pattern to expand into extension */
94
const char *conf = _PATH_CONF;	/* Configuration file to use */
96
const char *conf = _PATH_CONF;	/* Configuration file to use */
95
time_t timenow;
97
time_t timenow;
96
98
Lines 227-233 Link Here
227
	if ((p = strchr(hostname, '.'))) {
229
	if ((p = strchr(hostname, '.'))) {
228
		*p = '\0';
230
		*p = '\0';
229
	}
231
	}
230
	while ((c = getopt(argc, argv, "nrvFf:a:t:")) != -1)
232
	while ((c = getopt(argc, argv, "nrvFf:a:t:T:")) != -1)
231
		switch (c) {
233
		switch (c) {
232
		case 'n':
234
		case 'n':
233
			noaction++;
235
			noaction++;
Lines 248-253 Link Here
248
		case 'F':
250
		case 'F':
249
			force++;
251
			force++;
250
			break;
252
			break;
253
		case 'T':
254
			timename++;
255
			timearg = optarg;
256
			break;
251
		default:
257
		default:
252
			usage();
258
			usage();
253
		}
259
		}
Lines 516-521 Link Here
516
	int notified, need_notification, fd, _numdays;
522
	int notified, need_notification, fd, _numdays;
517
	struct stat st;
523
	struct stat st;
518
	pid_t pid;
524
	pid_t pid;
525
	time_t now;
519
526
520
#ifdef _IBMR2
527
#ifdef _IBMR2
521
	/*
528
	/*
Lines 633-638 Link Here
633
		if (noaction)
640
		if (noaction)
634
			printf("mv %s to %s\n", log, file1);
641
			printf("mv %s to %s\n", log, file1);
635
		else {
642
		else {
643
			/* change file1 to hold the new name */
644
			if (timename) {
645
				now = time( NULL );
646
				(void) strftime(file2, sizeof(file2), timearg, localtime( &now ) );
647
				if (archtodir)
648
					(void) snprintf(file1, sizeof(file1), "%s/%s.%s", dirpart, namepart, file2);
649
				else
650
					(void) snprintf(file1, sizeof(file1), "%s.%s", log, file2);
651
			}
652
636
			if (archtodir)
653
			if (archtodir)
637
				movefile(log, file1, perm, owner_uid,
654
				movefile(log, file1, perm, owner_uid,
638
				    group_gid);
655
				    group_gid);
Lines 683-708 Link Here
683
			    "log %s not compressed because daemon not notified",
700
			    "log %s not compressed because daemon not notified",
684
			    log);
701
			    log);
685
		else if (noaction)
702
		else if (noaction)
686
			printf("Compress %s.0\n", log);
703
			printf("Compress %s\n", file1);
687
		else {
704
		else {
688
			if (notified) {
705
			if (notified) {
689
				if (verbose)
706
				if (verbose)
690
					printf("small pause to allow daemon to close log\n");
707
					printf("small pause to allow daemon to close log\n");
691
				sleep(10);
708
				sleep(10);
692
			}
693
			if (archtodir) {
694
				(void) snprintf(file1, sizeof(file1), "%s/%s",
695
				    dirpart, namepart);
696
				if (flags & CE_COMPACT)
697
					compress_log(file1);
698
				else if (flags & CE_BZCOMPACT)
699
					bzcompress_log(file1);
700
			} else {
701
				if (flags & CE_COMPACT)
702
					compress_log(log);
703
				else if (flags & CE_BZCOMPACT)
704
					bzcompress_log(log);
705
			}
709
			}
710
			compress_log(file1);
711
			if (flags & CE_COMPACT)
712
				compress_log(file1);
713
			else if (flags & CE_BZCOMPACT)
714
				bzcompress_log(file1);
706
		}
715
		}
707
	}
716
	}
708
}
717
}
Lines 729-735 Link Here
729
	pid_t pid;
738
	pid_t pid;
730
	char tmp[MAXPATHLEN];
739
	char tmp[MAXPATHLEN];
731
740
732
	(void) snprintf(tmp, sizeof(tmp), "%s.0", log);
741
	(void) snprintf(tmp, sizeof(tmp), "%s", log);
733
	pid = fork();
742
	pid = fork();
734
	if (pid < 0)
743
	if (pid < 0)
735
		err(1, "gzip fork");
744
		err(1, "gzip fork");

Return to bug 29363