From owner-freebsd-questions Sat Apr 18 18:44:03 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA20037 for freebsd-questions-outgoing; Sat, 18 Apr 1998 18:44:03 -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 BAA19991 for ; Sun, 19 Apr 1998 01:43:43 GMT (envelope-from dkelly@nospam.hiwaay.net) Received: from nospam.hiwaay.net (tnt3-121.HiWAAY.net [208.147.146.121]) by fly.HiWAAY.net (8.8.8/8.8.6) with ESMTP id UAA32013; Sat, 18 Apr 1998 20:42:10 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by nospam.hiwaay.net (8.8.8/8.8.4) with ESMTP id SAA09431; Sat, 18 Apr 1998 18:12:52 -0500 (CDT) Message-Id: <199804182312.SAA09431@nospam.hiwaay.net> X-Mailer: exmh version 2.0.2 2/24/98 To: Alejandro Galindo cc: freebsd-questions@FreeBSD.ORG From: David Kelly Subject: Re: newsyslog process In-reply-to: Message from Alejandro Galindo of "Sat, 18 Apr 1998 06:51:13 MDT." <1.5.4.32.19980418125113.00714334@exsocom.com.mx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 18 Apr 1998 18:12:52 -0500 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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