From owner-freebsd-questions Sun Apr 19 20:10:41 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id UAA23651 for freebsd-questions-outgoing; Sun, 19 Apr 1998 20:10:41 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from fly.HiWAAY.net (root@fly.HiWAAY.net [208.147.154.56]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id DAA23612 for ; Mon, 20 Apr 1998 03:10:19 GMT (envelope-from dkelly@nospam.hiwaay.net) Received: from nospam.hiwaay.net (tnt2-84.HiWAAY.net [208.147.148.84]) by fly.HiWAAY.net (8.8.8/8.8.6) with ESMTP id WAA12830; Sun, 19 Apr 1998 22:09:00 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by nospam.hiwaay.net (8.8.8/8.8.4) with ESMTP id VAA08158; Sun, 19 Apr 1998 21:26:21 -0500 (CDT) Message-Id: <199804200226.VAA08158@nospam.hiwaay.net> X-Mailer: exmh version 2.0.2 2/24/98 To: Alejandro Galindo cc: David Kelly , freebsd-questions@FreeBSD.ORG From: David Kelly Subject: Re: newsyslog process In-reply-to: Message from Alejandro Galindo of "Sun, 19 Apr 1998 13:03:29 MDT." <1.5.4.32.19980419190329.0071e92c@exsocom.com.mx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 19 Apr 1998 21:26:21 -0500 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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