Bug 30471

Summary: periodic script output to a file always appends
Product: Base System Reporter: adrian <adrian>
Component: binAssignee: Brian Somers <brian>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff
none
file.diff none

Description adrian 2001-09-09 23:50:01 UTC
	If any of the *_output variables are set to files in
	periodic.conf, they will always append to the file.  This
	forces you to truncate the files through some external
	mechanism, which is cumbersome.

	It would be nice to have periodic know whether or not to
	preserve the old contents of the file by itself.  Since
	periodic.conf is just shell code, it is easy to implement
	complex self maintaining sets of logs.

	Consider the following settings in periodic.conf:

	daily_output="/var/log/periodic/daily.$(date +%d)"
	daily_output_clobber="YES"
        daily_status_security_output="/var/log/periodic/security.$(date +%d)"
        daily_status_security_output_clobber="YES"
        weekly_output="/var/log/periodic/weekly.$(date +%U)"
        weekly_output_clobber="YES"
        monthly_output="/var/log/periodic/monthly.$(date +%m)"
        monthly_output_clobber="YES"

	These settings allow local archiving of the output with
	automatic reuse of the old log files.  Dailies are kept
	for a month, weeklies and monthlies for a year.

	Note that this option opens the door to gzipping the output.
	To gzip, you must always clobber the old log file.

Fix: Apply the attached patches to the default periodic.conf
	and periodic.sh.  For historical compatability the default
	behavior is to append.
How-To-Repeat: 
	Set daily_output="/some/file" in periodic.conf and run
	'periodic daily' a few times to see that it always appends.
Comment 1 brian 2001-09-10 11:46:56 UTC
> >Number:         30471
> >Category:       bin
> >Synopsis:       periodic script output to a file always appends

Can the same functionality not be had by setting the _output 
variables as suggested in periodic.conf(5) ?  newsyslog(8) then gives 
all the rotation and compression flexibility that people might want.
-- 
Brian <brian@freebsd-services.com>                <brian@Awfulhak.org>
      http://www.freebsd-services.com/        <brian@[uk.]FreeBSD.org>
Don't _EVER_ lose your sense of humour !      <brian@[uk.]OpenBSD.org>
Comment 2 Brian Somers freebsd_committer freebsd_triage 2001-09-10 11:47:21 UTC
Responsible Changed
From-To: freebsd-bugs->brian

I'll look after this
Comment 3 Brian Somers freebsd_committer freebsd_triage 2001-09-17 23:07:01 UTC
State Changed
From-To: open->feedback

Awaiting feedback from original submitter
Comment 4 adrian 2001-09-18 02:58:17 UTC
	Sorry about the slow feedback.  I hald composed this and let it sit
for a few days due to my work load. :-(

On Mon, 10 Sep 2001, Brian Somers wrote:

> > >Number:         30471
> > >Category:       bin
> > >Synopsis:       periodic script output to a file always appends
>
> Can the same functionality not be had by setting the _output
> variables as suggested in periodic.conf(5) ?  newsyslog(8) then gives
> all the rotation and compression flexibility that people might want.

	Not quite.  newsyslog is very limited in its ability to rename
files.  Being able to have monthly logs named with their month as part of
their names just isn't possible through just newsyslog.  You can get pretty
close though with the right options to newsyslog, but if you say keep 31
daily logs, who know which one will hold the log for the first of the
month.  6 moths later the first might be in daily.15.

	My initial goal was to just have separate runs kept in separate
logs for each log type and have it be obvious which day went into which
file, so don't let my fancy use of $(date) in the *_output variables cloud
the situation.  It's just a nicety if you want to use something like
'$(date +%b)'.  Being able to maintain the logfiles and rotate them in a
single place isn't such a bad thing IMHO.  If you change the logfile names,
you need to change newsyslog.conf as well.

	All in all it can be argued that we have 6 of one and half a dozen
of the other, so I won't really press the issue.  I'm still rolling the
patch into a base-line appliance based off of FreeBSD because it's agreeable
to me.

	Adrian
--
[ adrian@ubergeeks.com ]
Comment 5 Brian Somers freebsd_committer freebsd_triage 2004-06-29 11:00:37 UTC
State Changed
From-To: feedback->closed

I don't think that clobbering output files is the right way to go on this. 

Ultimately, the same functionality can be obtained by having a separate 
cron job that runs after daily/weekly/montly runs and ``handles'' the log 
file, truncating it after it's been handled.