[plug] howto logging result to a log file
Jon Miller
jlmiller at mmtnetworks.com.au
Tue Aug 26 22:20:31 WST 2003
In my script the last thing I need to do is create a log file that
contains the output of the program plus the date and time of the entry.
Since I have no idea how to create a log file other than using (correct
me if I'm wrong) the >> to append to a file, my question is will this
add a new entry per line with the date to the left.
What I'm thinking is the following:
echo `date` mmpf >> /var/log/pstfxst.log
Does this seem correct?
Final script
#!/bin/sh
# postfixstatchk.sh
# Jon L. Miller, MCNE, CNS
# MMT Networks Pty Ltd
#
# Program to check mail and MMonitor status, if either has stopped
# then restart MMonitor and Postfix
#
# Procedure
# Check status of Postfix and Mail Monitor
# check status first, if equal to 0
# stop MM and Postfix
# restart MM and Postfix
#
#Variables
MTAPATH=/usr/sbin
MTA=postfix
MMPATH=/usr/local/sophos/mmsmtp-1.2.2/Linux-x86/bin
MMSP='mmsmtpd -terminate'
MMST='mmsmtpd -start'
MLSTAT=`pgrep -U postfix`
MMSTAT=`pgrep -u root mmsmtp.out`
#
#
# function to get a single figure from the mail monitor variable
function fmmstat()
{
vMMSTAT=`echo $MMSTAT | awk '{print $1}'`
echo $vMMSTAT
}
# function to get single figure from the mail variable
function fmlstat()
{
vMLSTAT=`echo $MLSTAT | awk '{print $1}'`
echo $vMLSTAT
}
#
# function to restart MM and postfix
function mmpf()
{
$MTAPATH/$MTA stop
$MMPATH/$MMSP
$MMPATH/$MMST
$MTAPATH/$MTA start
}
# check for existence of data
fmmstat
if [ "$vMMSTAT" -lt 1 ]; then
mmpf
fi
fmlstat
if [ "$vMLSTAT" -lt 1 ]; then
mmpf
fi
echo `date` mmpf >> /var/log/pstfxst.log
#
## End of Script
Problem is the last line only produces the date in the log file. There
should be 2 lines of information in it.
Thanks
--
Jon Miller <jlmiller at mmtnetworks.com.au
MMT Networks Pty Ltd
More information about the plug
mailing list