Newsyslog | Cronjob faulty?
Ian Smith
smithi at nimnet.asn.au
Fri May 18 19:03:41 UTC 2012
In freebsd-questions Digest, Vol 415, Issue 4, Message: 12
On Wed, 16 May 2012 21:44:53 +0200 Jos Chrispijn <kernel at 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
More information about the freebsd-questions
mailing list