From owner-freebsd-questions@FreeBSD.ORG Sun May 27 15:15:26 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6F772106567D for ; Sun, 27 May 2012 15:15:26 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from sola.nimnet.asn.au (paqi.nimnet.asn.au [115.70.110.159]) by mx1.freebsd.org (Postfix) with ESMTP id BDEF28FC12 for ; Sun, 27 May 2012 15:15:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by sola.nimnet.asn.au (8.14.2/8.14.2) with ESMTP id q4RFFCsW039464; Mon, 28 May 2012 01:15:13 +1000 (EST) (envelope-from smithi@nimnet.asn.au) Date: Mon, 28 May 2012 01:15:12 +1000 (EST) From: Ian Smith To: Jos Chrispijn Message-ID: <20120528010046.J98171@sola.nimnet.asn.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: freebsd-questions@freebsd.org Subject: Re: Newsyslog | Cronjob faulty? (fwd) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 May 2012 15:15:26 -0000 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 To: Jos Chrispijn 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 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