Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 May 2012 01:15:12 +1000 (EST)
From:      Ian Smith <smithi@nimnet.asn.au>
To:        Jos Chrispijn <kernel@webrz.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Newsyslog | Cronjob faulty? (fwd)
Message-ID:  <20120528010046.J98171@sola.nimnet.asn.au>

next in thread | raw e-mail | index | archive | help
Jos, did you not get my response to your original query over a week ago?

I see it made the list archives.  Anyway this second time around, Robert 
Bonomi wins gold for the best guess, with even fewer clues to go on :-)

cheers, Ian  (who probably said too much, but doesn't resile)

---------- Forwarded message ----------
Date: Sat, 19 May 2012 05:03:23 +1000 (EST)
From: Ian Smith <smithi@nimnet.asn.au>
To: Jos Chrispijn <kernel@webrz.net>
Cc: freebsd-questions@freebsd.org
Subject: Re: Newsyslog | Cronjob faulty?

In freebsd-questions Digest, Vol 415, Issue 4, Message: 12
On Wed, 16 May 2012 21:44:53 +0200 Jos Chrispijn <kernel@webrz.net> wrote:

 > At midnight (00.00) I run this cronjob from my crontab:
 > 
 > Crontab:
 > 00              *       *       *       *       root    newsyslog

By 'my' crontab, do you mean the system crontab, /etc/crontab ?

If so, that's nearly but not quite the default syntax of:

#minute hour    mday    month   wday    who     command
# Rotate log files every hour, if necessary.
0       *       *       *       *       root    newsyslog

Note the single '0'.  I don't know if '00' is valid.  And it doesn't 
mean 'at midnight', it means whenever the minute is 0, any hour, any 
day, any month, any weekday; ie newsyslog is run hourly, on the hour.

And the default entry in /etc/newsyslog.conf for maillog is:

/var/log/maillog                        640  7     *    @T00  JC

So it's newsyslog using newsyslog.conf(5) that creates maillog if it 
doesn't yet exist, rotates it to maillog.0 at midnight (T00), thereafter
compressing it with bzip2 (J).

 > For some reason this goes wrong; (if I run 'newsyslog' on any other 
 > time, there is no error message).
 > 
 > bzip2: Can't open input file /var/log/maillog.0: No such file or directory.
 > newsyslog: `bzip2 -f /var/log/maillog.0' terminated with a non-zero 
 > status (1)
 > 
 > /var/log:
 > -rw-r-----  1 root    wheel     63162 May 16 21:20 maillog
 > -rw-r-----  1 root    wheel       109 May 16 00:00 maillog.0.bz2
 > -rw-r-----  1 root    wheel     73674 May 16 00:00 maillog.1
 > -rw-r-----  1 root    wheel       111 May 15 00:00 maillog.2.bz2
 > -rw-r-----  1 root    wheel     73050 May 15 00:00 maillog.3
 > -rw-r-----  1 root    wheel       109 May 14 00:00 maillog.4.bz2
 > -rw-r-----  1 root    wheel    184042 May 14 00:00 maillog.5
 > 
 > Can somebody tell me what goes wrong here?

Looks likely two instances of newsyslog racing at midnight; one makes 
maillog.0.bz2 from the just-rolled maillog.0, the other finds maillog.0 
has disappeared before getting to run bzip2 on it?  So, two files per 
day, and the above message?

 > On my other FreeBSD server the same cronjob goes ok...

Check /etc/crontab and /etc/newsyslog.conf on both, and make sure you're 
not also trying to run a user crontab for root, apart from /etc/crontab?

cheers, Ian



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120528010046.J98171>