Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Apr 1998 21:26:21 -0500
From:      David Kelly <dkelly@hiwaay.net>
To:        Alejandro Galindo <agalindo@servidor.exsocom.com.mx>
Cc:        David Kelly <dkelly@hiwaay.net>, freebsd-questions@FreeBSD.ORG
Subject:   Re: newsyslog process 
Message-ID:  <199804200226.VAA08158@nospam.hiwaay.net>
In-Reply-To: Message from Alejandro Galindo <agalindo@servidor.exsocom.com.mx>  of "Sun, 19 Apr 1998 13:03:29 MDT." <1.5.4.32.19980419190329.0071e92c@exsocom.com.mx> 

next in thread | previous in thread | raw e-mail | index | archive | help
Alejandro Galindo writes:
> Thanks David, i put your code in a separate file (only for control the
> number of  wtmp.x  files, in your code the "x" are the date and i need a
> number (a consecutive number) )  then i call the program from the crontab;
> and its works like i want. 

I just grabbed what I had laying around. By placing the date in the new
file name you can easily know when it was rotated out, and be reasonably
assured there are no other files with the same name.

0 0 * * 6 root umask 2; if test -f /var/log/wtmp.next; then X=`cat \
/var/log/wtmp.next`; else X=0; echo 0 > /var/log/wtmp.next; fi; expr \
`cat /var/log/wtmp.next` + 1 > /var/log/wmtp.next; mv /var/log/wtmp \
/var/log/wtmp.$X; touch /var/log/wtmp; chown root.bin /var/log/wtmp;\
gzip /var/log/wtmp.$X

Think you are right to move this out of your crontab into a separate
file. I'm getting silly seeing how much I can stuff into it. Would be
best if you tested for the existence of wtmp.$X before moving a file on
top of it (exercise left for the reader).

But best of all, 2.2.6-RELEASE or 2.2.6-STABLE has moved this out of
newsyslog into /etc/monthly. Wtmp's moved there are tagged with the
month name. Then login accounting is performed. By rotating your wtmp
every week you stand to scramble the value of a monthly login accounting
report. Maybe you should simply fix the filename for the monthly rotated
wtmp and run /etc/monthly every week? Or move wtmp and login accounting
into /etc/weekly.


--
David Kelly N4HHE, dkelly@nospam.hiwaay.net
=====================================================================
The human mind ordinarily operates at only ten percent of its
capacity -- the rest is overhead for the operating system.



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



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