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

Collapse All | Expand All

(-)newsyslog/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 349-354 Link Here
349
to trim the logs, even if the trim conditions have not been met.  This
350
to trim the logs, even if the trim conditions have not been met.  This
350
option is useful for diagnosing system problems by providing you with
351
option is useful for diagnosing system problems by providing you with
351
fresh logs that contain only the problems.
352
fresh logs that contain only the problems.
353
.It Fl T
354
Time based extension
355
.Nm
356
to rename all logs that get trimmed into with an extension based on the
357
argument given by this option. This option can be any strfime(3) string.
358
 This function is intended for permantely storing of logfiles.  If the
359
patten results to an already existing file, operations breaks without
360
cleanup, leaving stale logs in place, that might be ovewritten.
352
.El
361
.El
353
.Pp
362
.Pp
354
If additional command line arguments are given,
363
If additional command line arguments are given,
(-)newsyslog/newsyslog.c (-9 / +21 lines)
Lines 86-92 Link Here
86
int needroot = 1;		/* Root privs are necessary */
86
int needroot = 1;		/* Root privs are necessary */
87
int noaction = 0;		/* Don't do anything, just show it */
87
int noaction = 0;		/* Don't do anything, just show it */
88
int force = 0;			/* Force the trim no matter what */
88
int force = 0;			/* Force the trim no matter what */
89
int timename = 0;		/* Use time of rotation as suffix */
89
char *archdirname;		/* Directory path to old logfiles archive */
90
char *archdirname;		/* Directory path to old logfiles archive */
91
char *timearg;			/* Pattern to expand into extension */
90
char *conf = _PATH_CONF;	/* Configuration file to use */
92
char *conf = _PATH_CONF;	/* Configuration file to use */
91
time_t timenow;
93
time_t timenow;
92
94
Lines 214-220 Link Here
214
	if ((p = strchr(hostname, '.'))) {
216
	if ((p = strchr(hostname, '.'))) {
215
		*p = '\0';
217
		*p = '\0';
216
	}
218
	}
217
	while ((c = getopt(argc, argv, "nrvFf:a:t:")) != -1)
219
	while ((c = getopt(argc, argv, "nrvFf:a:t:T:")) != -1)
218
		switch (c) {
220
		switch (c) {
219
		case 'n':
221
		case 'n':
220
			noaction++;
222
			noaction++;
Lines 235-240 Link Here
235
		case 'F':
237
		case 'F':
236
			force++;
238
			force++;
237
			break;
239
			break;
240
		case 'T':
241
			timename++;
242
			timearg = optarg;
243
			break;
238
		default:
244
		default:
239
			usage();
245
			usage();
240
		}
246
		}
Lines 483-488 Link Here
483
	int notified, need_notification, fd, _numdays;
489
	int notified, need_notification, fd, _numdays;
484
	struct stat st;
490
	struct stat st;
485
	pid_t pid;
491
	pid_t pid;
492
	time_t now;
486
493
487
#ifdef _IBMR2
494
#ifdef _IBMR2
488
	/*
495
	/*
Lines 581-586 Link Here
581
		if (noaction)
588
		if (noaction)
582
			printf("mv %s to %s\n", log, file1);
589
			printf("mv %s to %s\n", log, file1);
583
		else {
590
		else {
591
			/* change file1 to hold the new name */
592
			if (timename) {
593
				now = time( NULL );
594
				(void) strftime(file2, sizeof(file2), timearg, localtime( &now ) );
595
				if (archtodir)
596
					(void) snprintf(file1, sizeof(file1), "%s/%s.%s", dirpart, namepart, file2);
597
				else
598
					(void) snprintf(file1, sizeof(file1), "%s.%s", log, file2);
599
			}
600
584
			if (archtodir)
601
			if (archtodir)
585
				movefile(log, file1, perm, owner_uid, group_gid);
602
				movefile(log, file1, perm, owner_uid, group_gid);
586
			else
603
			else
Lines 628-646 Link Here
628
		if (need_notification && !notified)
645
		if (need_notification && !notified)
629
			warnx("log %s not compressed because daemon not notified", log);
646
			warnx("log %s not compressed because daemon not notified", log);
630
		else if (noaction)
647
		else if (noaction)
631
			printf("Compress %s.0\n", log);
648
			printf("Compress %s\n", file1);
632
		else {
649
		else {
633
			if (notified) {
650
			if (notified) {
634
				if (verbose)
651
				if (verbose)
635
					printf("small pause to allow daemon to close log\n");
652
					printf("small pause to allow daemon to close log\n");
636
				sleep(10);
653
				sleep(10);
637
			}
638
			if (archtodir) {
639
				(void) snprintf(file1, sizeof(file1), "%s/%s", dirpart, namepart);
640
				compress_log(file1);
641
			} else {
642
				compress_log(log);
643
			}
654
			}
655
			compress_log(file1);
644
		}
656
		}
645
	}
657
	}
646
}
658
}
Lines 667-673 Link Here
667
	pid_t pid;
679
	pid_t pid;
668
	char tmp[MAXPATHLEN];
680
	char tmp[MAXPATHLEN];
669
681
670
	(void) snprintf(tmp, sizeof(tmp), "%s.0", log);
682
	(void) snprintf(tmp, sizeof(tmp), "%s", log);
671
	pid = fork();
683
	pid = fork();
672
	if (pid < 0)
684
	if (pid < 0)
673
		err(1, "fork");
685
		err(1, "fork");

Return to bug 29363