Random Sequence

The fetchmail daemon sometimes gives up without good reason. The following script should be placed in /etc/cron.quarter-hourly/ or similar to check it’s running. This script assumes your fetchmailrc does not contain a set daemon line, and contains set logfile /var/log/fetchmail.log

Sponsored Links:

Using Cron to Restart Fetchmail

In addition, fetchmail sometimes hangs without exiting. For this reason, I suggest adding the second script to /etc/cron.quarter-daily/ to exit fetchmail and then restart

      ADMIN=fetchmail-server-error@admindomain.com

  #!/bin/sh
  if ps -auxc | grep fetchmail ; then
   exit 0
  else
  # echo "No Fetchmail!"
  /usr/bin/fetchmail -d 120
  mail -s "fetchmail(`uname -n`) restarted @ `date`" $ADMIN <<EOF
  Fetchmail had to be restarted.
  `tail /var/log/fetchmail.log`
  EOF
  exit 0
  fi

Second Script:

ADMIN=fetchmail-server-error@admindomain.com

  #!/bin/sh

  fetchmail -q
  fetchmail -d 180
  exit 0

Sponsored Links: