Daniel de los Reyes wrote:
> I want to run fetchmail as a daemon each time I log in but I don't want to
> do it manually.Is bash_profile the apropiate place to launch it from? How
> can I prevent it form being launched several times if I login at several
> consoles?
Here's how I do it. First, I wrote a script called fetchmail.sh, which is
located in my home directory. Here's the script:
----- Begin fetchmail.sh -----
#! /bin/bash
LOGCOUNT=w -hsf|grep mike|wc -l
MAXCOUNT=1
case "$1" in
start-daemon)
if [ -e ~mike/.fetchmail.pid ]
then
exit
fi
fetchmail -d 120
;;
start)
if [ -e ~mike/.fetchmail.pid ]
then
exit
fi
fetchmail
;;
stop-daemon)
if [ ! -e ~mike/.fetchmail.pid ]
then
exit
fi
if [ $LOGCOUNT -eq $MAXCOUNT ]
then
fetchmail --quit
fi
;;
esac
exit 0
----- End fetchmail.sh -----
Yes, I know that this script is kinda ugly. But it works, and that's all I
was after.
In my ~/.bash_profile I have a call to "~/fetchmail.sh start-daemon" and in
my ~/.bash_logout I have a call to "~/fetchmail.sh stop-daemon"
This script could probably be cleaned up some, but like I said *it* *works*
for me.
--
Mike Werner KA8YSD | He that is slow to believe anything and
| everything is of great understanding,
'91 GS500E | for belief in one false principle is the
Morgantown WV | beginning of all unwisdom.
Attachment:
pgplA6RnfqtQd.pgp
Description: PGP signature