/etc/rc

It will be necessary to start up the sendmail daemon when your system reboots. This daemon performs two functions: it listens on the SMTP socket for connections (to receive mail from a remote system) and it processes the queue periodically to insure that mail gets delivered when hosts come up.

Add the following lines to /etc/rc (or /etc/rc.local as appropriate) in the area where it is starting up the daemons:

if [ -f /usr/sbin/sendmail -a -f /etc/sendmail.cf ]; then
(cd /var/spool/mqueue; rm -f [lnx]f*)
/usr/sbin/sendmail -bd -q30m &
echo -n ' sendmail' >/dev/console
fi
The cd and rm commands insure that all lock files have been removed; extraneous lock files may be left around if the system goes down in the middle of processing a message. The line that actually invokes sendmail has two flags: -bd causes it to listen on the SMTP port, and -q30m causes it to run the queue every half hour.

Some people use a more complex startup script, removing zero length qf files and df files for which there is no qf file. For example, see Figure 1 for an example of a complex startup script.



# remove zero length qf files
for qffile in qf*
do
if [ -r $qffile ]
then
if [ ! -s $qffile ]
then
echo -n " <zero: $qffile>" > /dev/console
rm -f $qffile
fi
fi
done
# rename tf files to be qf if the qf does not exist
for tffile in tf*
do
qffile=`echo $tffile | sed 's/t/q/'`
if [ -r $tffile -a ! -f $qffile ]
then
echo -n " <recovering: $tffile>" > /dev/console
mv $tffile $qffile
else
echo -n " <extra: $tffile>" > /dev/console
rm -f $tffile
fi
done
# remove df files with no corresponding qf files
for dffile in df*
do
qffile=`echo $dffile | sed 's/d/q/'`
if [ -r $dffile -a ! -f $qffile ]
then
echo -n " <incomplete: $dffile>" > /dev/console
mv $dffile `echo $dffile | sed 's/d/D/'`
fi
done
# announce files that have been saved during disaster recovery
for xffile in [A-Z]f*
do
echo -n " <panic: $xffile>" > /dev/console
done


Figure 1 -- A complex startup script



If you are not running a version of UNIX that supports Berkeley TCP/IP, do not include the -bd flag.


[Contents] [Previous] [Next]


Questions or problems regarding this web site should be directed to Steve Gielda.
Copyright 1999 www.cotse.com.  All rights reserved.
Last modified: Friday April 02, 1999.