Re: run command on logfile before it's rotated

2002-12-05 Thread Andrew Prewett
Today Akifyev Sergey wrote:

 On Thu, 2002-12-05 at 01:02, Nathan Kinkade wrote:
  On Wed, Dec 04, 2002 at 10:51:43PM +0100, Thomas von Hassel wrote:
   I've got my system set up to rotate the maillog every day at midnight.
   What do i do if i want to run a command on the logfile just before it's
   rotated ?
  
   /thomas
   --
   Thomas von Hassel
   DarX @ irc
   darxmac @ AIM/iChat
   Powered by inkwell...!
 
  How about just setting a cron job to run some reasonable period prior
  to newsyslog being run?

 It's incorrect way to do things, because some entries could be added to
 syslog _after_ the command is run, but _before_ newsyslog. Instead you
 should call some script via cron with crontab entry like this:

 # rotate log files every hour, if necessary
 0   *   *   *   *   root  /usr/bin/lock_script.sh

 And the script must contain something like:

 #!/bin/sh
 for $STR in `cat /etc/newsyslog.conf |grep -v '^[:space:]*#.*$'|cut
 -f1`; do
   lockf ${STR} newsyslog.sh ${STR}
 done

 This is _advisory_ lock, not _mandatory_. Syslogd could write to the
file happily while `your_command' is running or/and between `your_command'
and newsyslog.

Maybe this is a little closer (not tested):
kill -17 syslogd pid; my_scrypt; newsyslog; kill -19 syslogd pid
Ie.: STOP syslogd; run the script(s); rotate logs; CONTinue syslogd.
But if there is to much logging between the two signals, then messages could
be lost.

-andrew


 The newsyslog.sh should contain:

 #!/bin/sh
 your_command ${1}
 newsyslog ${1}


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



run command on logfile before it's rotated

2002-12-04 Thread Thomas von Hassel
I've got my system set up to rotate the maillog every day at midnight. 
What do i do if i want to run a command on the logfile just before it's 
rotated ?

/thomas
--
Thomas von Hassel
DarX @ irc
darxmac @ AIM/iChat
Powered by inkwell...!


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message


Re: run command on logfile before it's rotated

2002-12-04 Thread Dan Nelson
In the last episode (Dec 04), Thomas von Hassel said:
 I've got my system set up to rotate the maillog every day at
 midnight.  What do i do if i want to run a command on the logfile
 just before it's rotated ?

Run it via cron at 11:59?  newsyslog can notify a process (via a
signal) after it has rotated the log, but not before.

-- 
Dan Nelson
[EMAIL PROTECTED]

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message



Re: run command on logfile before it's rotated

2002-12-04 Thread Akifyev Sergey
On Thu, 2002-12-05 at 01:02, Nathan Kinkade wrote:
 On Wed, Dec 04, 2002 at 10:51:43PM +0100, Thomas von Hassel wrote:
  I've got my system set up to rotate the maillog every day at midnight. 
  What do i do if i want to run a command on the logfile just before it's 
  rotated ?
  
  /thomas
  --
  Thomas von Hassel
  DarX @ irc
  darxmac @ AIM/iChat
  Powered by inkwell...!
 
 How about just setting a cron job to run some reasonable period prior 
 to newsyslog being run?

It's incorrect way to do things, because some entries could be added to
syslog _after_ the command is run, but _before_ newsyslog. Instead you
should call some script via cron with crontab entry like this:

# rotate log files every hour, if necessary
0   *   *   *   *   root/usr/bin/lock_script.sh 

And the script must contain something like:

#!/bin/sh
for $STR in `cat /etc/newsyslog.conf |grep -v '^[:space:]*#.*$'|cut
-f1`; do
lockf ${STR} newsyslog.sh ${STR}
done

The newsyslog.sh should contain:

#!/bin/sh
your_command ${1}
newsyslog ${1}

 Nathan
 
 To Unsubscribe: send mail to [EMAIL PROTECTED]
 with unsubscribe freebsd-questions in the body of the message
 

Regards,
Sergey


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-questions in the body of the message