Bug 115486

Summary: [patch] [request] newsyslog(8) -- provide ability to compress Nth rotated file
Product: Base System Reporter: david
Component: binAssignee: Marcelo Araujo <araujo>
Status: Closed FIXED    
Severity: Affects Some People CC: Artis.Caune, araujo, ben.rubson, ler
Priority: Normal Keywords: patch
Version: 7.0-CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff
none
Provide ability to compress Nth rotated file, FBSD11 none

Description david 2007-08-14 00:30:01 UTC
	As it stands, newsyslog(8) provides for optional compression for
	rotated files.

	However, that compression only takes place for the newly-created
	".0" file.

	Artis Caune <Artis.Caune@latnet.lv> suggested (in -hackers@)
	that providing an ability to defer the compression to the
	".1" file might be useful for certain applications, such
	as apache.

	Dirk GOUDERS <gouders@et.bocholt.fh-ge.de> followed up,
	suggesting the use of the "0" flag, which is an enhancement
	available in another implementation of newsyslog(8).

	I mentioned that while this might be useful, it would still fall
	short of something I needed to do at work recently: leave the
	newest N rotated log files uncompressed, while compressing the
	others.

	After a small amount of additional discussion, Dirk volunteered
	to supply patches; I volunteered to test (and later, to hack the
	man page).

	Dirk supplied the patches; I tested to my satisfaction, and
	attacked the man page.  The attached patches are the result.

Fix: Apply the following patches in /usr/src/usr.sbin/newsyslog,
	then make  && make install.  That done, the "generation number"
	of the rotated file that is to be compressed may be specified in
	the "flags" field of a newsyslog.conf entry:

How-To-Repeat: 	Try to figure out  how to get newsyslog(8) to only compress a
	rotated log file if it exceeds a certain "age" (or "generation
	number").  If you figure out a way, please document it. :-}
Comment 1 Ben RUBSON 2017-02-20 08:25:03 UTC
This patch would be really useful for Apache :
http://httpd.apache.org/docs/current/stopping.html
"At present there is no way for a log rotation script using USR1 to know for certain that all children writing the pre-restart log have finished. We suggest that you use a suitable delay after sending the USR1 signal before you do anything with the old log."

So this patch really helps, as we can then choose not to compress the first rotated file.

Could we think about committing / MFCing it please ?

Many thanks !

Ben
Comment 2 david 2017-02-28 18:57:41 UTC
Updated to reflect "Affects some people" (per request).
Comment 3 Ben RUBSON 2017-03-21 15:55:41 UTC
Created attachment 181029 [details]
Provide ability to compress Nth rotated file, FBSD11
Comment 4 Ben RUBSON 2017-03-21 15:56:24 UTC
Attached is an updated (an tested) patch for FreeBSD11.
Could we think about merging it please ?
Thank you very much !
Ben
Comment 5 Ben RUBSON 2017-04-14 06:32:05 UTC
Many thanks Marcelo !
Comment 6 Ben RUBSON 2018-01-03 09:31:19 UTC
Just solved in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=162798 ?