Restarting fetchmail automatically

I use fetchmail (in daemon mode) to pull down mail from a POP server to my local box, where I then serve it up with the Courier IMAP server. Problem I had was when my box rebooted, fetchmail could not automatically restart because it needs a password to proceed (I don’t want to store the password in my .fetchmailrc). My solution was to add the following to my .bashrc:

if [ -x "/usr/local/bin/fetchmail" ]; then
  if ! killall -0 fetchmail 2> /dev/null; then
     echo "killall -0 fetchmail failed - starting fetchmail..."
     fetchmail
  fi
fi

Leave a Reply

Your email address will not be published.