Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Apr 1998 18:12:52 -0500
From:      David Kelly <dkelly@hiwaay.net>
To:        Alejandro Galindo <agalindo@servidor.exsocom.com.mx>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: newsyslog process 
Message-ID:  <199804182312.SAA09431@nospam.hiwaay.net>
In-Reply-To: Message from Alejandro Galindo <agalindo@servidor.exsocom.com.mx>  of "Sat, 18 Apr 1998 06:51:13 MDT." <1.5.4.32.19980418125113.00714334@exsocom.com.mx> 

next in thread | previous in thread | raw e-mail | index | archive | help
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



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