From owner-freebsd-questions Sun Apr 19 10:59:18 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA02530 for freebsd-questions-outgoing; Sun, 19 Apr 1998 10:59:18 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from servidor.exsocom.com.mx (servidor.exsocom.com.mx [200.34.46.130]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id RAA02505 for ; Sun, 19 Apr 1998 17:59:07 GMT (envelope-from agalindo@servidor.exsocom.com.mx) Received: from servidor.exsocom.com.mx.exsocom.com.mx ([200.34.46.166]) by servidor.exsocom.com.mx (8.8.7/8.8.5) with SMTP id NAA16978; Sun, 19 Apr 1998 13:04:28 -0500 (CDT) Message-Id: <1.5.4.32.19980419190329.0071e92c@exsocom.com.mx> X-Sender: agalindo@exsocom.com.mx X-Mailer: Windows Eudora Light Version 1.5.4 (32) Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Sun, 19 Apr 1998 13:03:29 -0600 To: David Kelly From: Alejandro Galindo Subject: Re: newsyslog process Cc: freebsd-questions@FreeBSD.ORG Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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. Thank you very much Alejandro At 06:12 PM 18/04/98 -0500, you wrote: >You are trying to do it the hard way. > >Alejandro Galindo writes: >> Hellow, i need to configure a separate newsyslog process for the next task: >> >> every day 6 of the week i need to run the newsyslog for rotate the file wtmp >> >> in the cron tab file i put the next line >> ---------cut here--------- >> 0 0 * * 6 root /usr/local/bin/mynewsyslog >> ---------cut here--------- >> >> the mynewsyslog file are the next: >> >> -------cut here--------- >> #!/usr/local/bin/perl >> # Rotate the wtmp actual file >> system("/usr/sbin/newsyslog -f /etc/newsyslog.wtmp"); >> -------cut here--------- > >First "hard way" shown above. Rather than create a "mynewsyslog", >simply run "/usr/sbin/newsyslog -f /etc/newsyslog.wtmp" from the >crontab. However there is an even simpler way. > >> i need to rotate the file exactly at 00:00 hrs in the day 6 of the week, and >> in the last file i specify the time = 0 (0 hrs). > >Newsyslog runs and decides *if* the files in its config need to be >rotated. You want the file to be rotated no matter what, so why don't >you simply rotate it in the crontab? > >0 0 * * 6 root umask 2; DATE=`date +\%Y\%m\%d`; mv /var/log/wtmp \ >/var/log/wtmp.$DATE; touch /var/log/wtmp; chown root.bin /var/log/wtmp;\ >gzip /var/log/wtmp.$DATE > >You might not have to umask or chown as shown above, it doesn't hurt. >The above idea was borrowed from SGI's root crontab. Lately I've been >considering porting newsyslog to SGI, or using the perl lumberjack. > >Hmmm. Checking recent sources I see rotation of wtmp is no longer >handled by newsyslog but happens in /etc/monthly. Guessing this is so >monthly accounting works right. > >nospam: {261} pwd >/usr/src/etc >nospam: {262} ls -l monthly newsyslog.conf >-rw-r--r-- 1 root wheel 527 Feb 9 05:44 monthly >-rw-r--r-- 1 root wheel 570 Apr 16 20:02 newsyslog.conf >nospam: {263} > >-- >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 > > ---------------------------------------------------------------------------- | , , | | /( )` | | \ \___ / | | | /- _ `-/ ' | | (/\/ \ \ /\ | | ExSoCom Dgo. MEXICO / / | ` \ | | O O ) / | | | `-^--'`< ' | | (_.) _ ) / | | Alejandro Galindo Chairez `.___/` / | | Tel: (52 18) 179177 `-----' / | | Fax: (52 18) 179177 <----. __ / __ \ | | <----|====O)))==) \) /==== | | e-mail agalindo@exsocom.com.mx <----' `--' `.__,' \ | | | | | | http://www.exsocom.com.mx \ / /\| | ______( (_ / \______/ | | ,' ,-----' | | | a FreeBSD user `--{__________) | ---------------------------------------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message