[prog] bash scipt question

Chris Henderson henders254 at gmail.com
Mon Jul 28 07:47:55 UTC 2008


I am writing a script that will collect SNMP information from a switch
to a log file; once the file reaches
"x" bytes, it will stop the process, rotate the log (via logrotate)
and will start the process again.
I am having some issues with rotating the logs and starting the
process again. Here's my script -

# call the snmp collect script
BINARY="/home/snmp/snmp_collect.sh"

EGREP="/usr/bin/egrep"
OPTIONS="ipaddress|macaddress"

LOG="/home/snmp/logs/snmp.log"

$BINARY | $EGREP | $OPTIONS > $FILE 2>&1 &

if ["`ls -al $LOG | awk '{print $5}'`" -gt "10485760"]; then
 pkill snmp_collect
 logrotate to snmp.log.1
 <start collecting log again until the log file reaches "x" bytes"
fi

Any help would be much appreciated. Thanks.


More information about the Programming mailing list