I'm collecting sflow data from a switch to a file. At 2300 every night I want
to roll-over the file to file.1 and start with a new file. But it looks like
the log rotation is not happening : at 2200 my sflow data collection stops.
Following is the way I'm doing it.
collect.sh shell script calls a C program to collect the sflow data,
filter the output and send the filtered data to /tmp/sflow.log file. I run
this script from the CLI as root:
collect.sh script:
Code:
EXE="/bin/sflowtool/sflowtool"
EGREP="/bin/egrep"
FILTER="dstIP|srcIP|IPProtocol|rcPort|stPort"
FILE="/tmp/sflow.log"
$EXE | $EGREP "$FILTER" > $FILE 2>&1 &
rotate.sh kills any "sflow" process (or PID) and is supposed to rotate the
/tmp/sflow.log log to /tmp/sflow.log.1 and
start the collect.sh shell script again & starts collecting log to /tmp/sflow.log. I run
this script from root's crontab as:
Quote:
0 23 * * * /bin/rotate.sh > "/var/log/lorgorate.`/bin/date +\%a`.log" 2>&1
|
rotate.sh script:
Code:
EXE="/bin/sflow_collect.sh"
PKILL="/usr/bin/pkill"
LOGROTATE="/usr/sbin/logrotate"
LOGROTATE_FILE="sflow_logrotate"
$PKILL -9 sflow
$LOGROTATE -f $LOGROTATE_FILE
$EXE
sflow_logrotate file:
Code:
/tmp/sflow.log {
rotate 30
nocompress
create
}
Thanks for any help.