Bug 230961 - man page for newsyslog.conf(5) says that when specified, "BOTH" size conditions must be met. It should be "EITHER".
Summary: man page for newsyslog.conf(5) says that when specified, "BOTH" size conditio...
Status: Closed Not A Bug
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-27 20:46 UTC by Jamie Landeg-Jones
Modified: 2018-08-29 17:30 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jamie Landeg-Jones 2018-08-27 20:46:49 UTC

    
Comment 1 Jamie Landeg-Jones 2018-08-27 20:49:04 UTC
The man page for newsyslog.conf(5) says that if both a size and a time interval are specified, BOTH conditions must be satisfied for the file rotation to take place:

 > Time based trimming happens only if newsyslog(8) is run within one hour of the specified time.  If an interval is specified, the log file will be trimmed if that many hours have passed since the last rotation.  When both a time and an interval are specified then both conditions must be satisfied for the rotation to take place.

This is wrong. The rotation will take place if EITHER condition takes place.

Consider this test, creating an entry that will be rotated when the file size reaches 10Mb, and the file is older than a day:

Cheers, Jamie

# echo "/tmp/test 555 10 10000 24 N" >> /etc/newsyslog.conf

# touch /tmp/test

# newsyslog -v /tmp/test
Processing /etc/newsyslog.conf
Found: <include> /etc/newsyslog.conf.d/*
Found: <include> /usr/local/etc/newsyslog.conf.d/*
/tmp/test <10>: size (Kb): 0 [10000]  age (hr): -1 [24] --> trimming log....

# l /tmp/test*
4 -r-xr-xr-x  1 root  wheel  - 61 27 Aug 21:07 /tmp/test
4 -r-xr-xr-x  1 root  wheel  - 61 27 Aug 21:07 /tmp/test.0

# newsyslog -v /tmp/test
Processing /etc/newsyslog.conf
Found: <include> /etc/newsyslog.conf.d/*
Found: <include> /usr/local/etc/newsyslog.conf.d/*                                                                                                                                                                                                                                                                                                                                                                                                                                              /tmp/test <10>: size (Kb): 1 [10000]  age (hr): 0 [24] --> skipping
# dd if=/dev/random bs=1k count=10 | od -c > /tmp/test
10+0 records in                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 10+0 records out
10240 bytes transferred in 0.000317 secs (32312115 bytes/sec)

# l /tmp/test*
48 -r-xr-xr-x  1 root  wheel  - 47,103 27 Aug 21:09 /tmp/test
 4 -r-xr-xr-x  1 root  wheel  -     61 27 Aug 21:07 /tmp/test.0                                                                                                                                                                                                                                                                                                                                                                                                                                 
# newsyslog -v /tmp/test
Processing /etc/newsyslog.conf
Found: <include> /etc/newsyslog.conf.d/*
Found: <include> /usr/local/etc/newsyslog.conf.d/*
/tmp/test <10>: size (Kb): 46 [10000]  age (hr): 0 [24] --> skipping

# l /tmp/test*
48 -r-xr-xr-x  1 root  wheel  - 47,103 27 Aug 21:09 /tmp/test
 4 -r-xr-xr-x  1 root  wheel  -     61 27 Aug 21:07 /tmp/test.0

# touch -r /COPYRIGHT /tmp/test.0

# l /tmp/test*
48 -r-xr-xr-x  1 root  wheel  - 47,103 27 Aug 21:09 /tmp/test
 4 -r-xr-xr-x  1 root  wheel  -     61 24 Jun  2017 /tmp/test.0

# newsyslog -v /tmp/test
Processing /etc/newsyslog.conf
Found: <include> /etc/newsyslog.conf.d/*
Found: <include> /usr/local/etc/newsyslog.conf.d/*
/tmp/test <10>: size (Kb): 46 [10000]  age (hr): 10302 [24] --> trimming log....

# l /tmp/test*
 4 -r-xr-xr-x  1 root  wheel  -     61 27 Aug 21:10 /tmp/test
48 -r-xr-xr-x  1 root  wheel  - 47,164 27 Aug 21:10 /tmp/test.0
 4 -r-xr-xr-x  1 root  wheel  -     61 24 Jun  2017 /tmp/test.1
Comment 2 Jamie Landeg-Jones 2018-08-27 21:01:34 UTC
(Testing also shows that the rotation takes place if the size is exceeded but the age isn't)
Comment 3 Mark Johnston freebsd_committer freebsd_triage 2018-08-28 21:34:31 UTC
(In reply to Jamie Landeg-Jones from comment #1)
It sounds like the documentation is says that the "when" field may contain both a time and an interval, and that both constraints must be satisfied for rotation to occur.  For example, 24@T00, meaning "rotate at midnight if it's been at least 24 hours since the last rotation."  As far I can tell, the documentation isn't referring to the "size" field at all in the paragraph that you quoted.
Comment 4 Mark Johnston freebsd_committer freebsd_triage 2018-08-29 17:30:45 UTC
I think the quoted paragraph is correct.  Please re-open the bug if you disagree.