Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to automate email retrieval



Jean-Christian Imbeault <jean_christian@example.com> writes in tlug@example.com:

>> Yup.  Do something like `fetchmail -d 120'.
> I've gotten fetchmail to work as a daemon, but I don't think this means it 
> gets restarted when the machine reboots or keep going when you logout or 
> even that it restarts itself it it dies for some reason.

It needs to be restarted after machine reboot, but it will continue to
run after logging out.  Since I reboot the workstation I read email on
so infrequently, I start it by hand.

Note that if fetchmail gets wedged for any reason, the easiest way to
kill it and restart is by using the sequence `fetchmail -q; fetchmail
-d 120'

> I'm new to linux sysadmin and I'm just wondering what is the "proper"
> way of getting fetchmail to always be up and running as a deamon. If
> it to ask each user to make a cron job or is there some way I can do
> this as root and have fetchmail run system wide for each user?

This is Unix.  There is no single best way to do it.  Since I use
fetchmail in combination with ssh and want it to run completely
unattended, I have to make sure I've started ssh-agent first.  I do
this by saving the output of ssh-agent, running ssh-add to enter my
passphrase and then I start fetchmail.

$ Host=$(hostname | cut -d. -f1)
$ ssh-agent > ssh-agent.$Host
$ source ssh-agent.$Host
$ ssh-add
 [manually type passphrase]
$ fetchmail -d 120
$ exit

Then in my .zshrc I do:
Host=$(hostname | cut -d. -f1)
if [ -z "$SSH_AGENT_PID" -a -f "$HOME/ssh-agent.$Host" ]; then
        source $HOME/ssh-agent.$Host
fi


Admittedly, that's a bit of typing, but it doesn't bother me when I
only have to do it once every five or six months.

If you want to do this for every user, your email is being spooled on
the wrong machine and perhaps you should revisit your MTA setup there.
Using .forward files may be more convenient.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links