Starting fetchmail in daemon mode from cron

From: Night Owl (Night.Owl_at_dark.scary.night.nodomain)
Date: 07/13/05


Date: Tue, 12 Jul 2005 22:49:51 -0400

Cross posted: comp.os.linux.admin,comp.os.linux,alt.os.linux

I'd appreciate some help with the following:

I'm trying to get fetchmail tweaked to poll based on usage conditions:

- users logged on to their IMAP store = poll very frequently,
providing a "near realtime" experience (accounts for about 2
hours/day)
- no users logged on toe their IMAP store = poll occasionally

My intent is to have the cron script fire once every 5 minutes and, if
needed, tweak fetchmail's daemon mode by unloading / re-loading the
fetchmail process. I think that this is a better approach than
running the script every minute and manually polling when appropriate
(in case you wonder why I choose one approach over the other).

The script works fine from a command line in that it kills the running
process as needed and re-loads fetchmail with the appropriate command
line parameters.

Calling it from cron is a different story, however. The script fires
and will kill the fetchmail process but won't start up a new one. For
simplicity sake, I have boiled down the script to a few essentials for
testing purposes.

I can't figure this one out and would really appreciate your help.

Here are the details:

# cat /etc/crontab
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""
HOME=/
# ---------- ---------- Default is Empty ---------- ---------- #
0 0-23/8 * * * root /usr/sbin/CheckDiskFull &>/dev/null
0 0 * * * root /usr/sbin/WatchDog &>/dev/null
1 * * * * root /usr/sbin/hwclock -s &>/dev/null
*/5 * * * * root /myscripts/fetchmailcustom
#

# ls -all /myscripts
drwxr-xr-x 2 root root 4096 Jul 10 11:10 .
drwxrwxr-x 24 admin everyone 4096 Jul 7 22:01 ..
-rwxr-xr-x 1 root root 217 Jul 10 11:07 fetchmailcustom
-rw-r--r-- 1 root root 0 Jul 10 12:12
fetchmailcustom.imap
-rwxr-xr-x 1 root root 1895 Jul 10 11:06 fmbackup
#

#!/bin/sh
/bin/killall fetchmail 2>/dev/null
/opt/bin/fetchmail -d 90 -t 60 -a -e 50 --auth password -f
/opt/etc/fetchm
ailrc -L /var/log/fetchmail 2>&1
touch /myscripts/fetchmailcustom.imap

#

Platform:
Linksys NSLU2

Installed packages:
fetchmail - 6.2.5-6

kernel-image-2.4.22-xfs - 2.3r29-r2
kernel-module-ftdi-sio - 2.3r29-r2
kernel-module-kaweth - 2.3r29-r2
kernel-module-pegasus - 2.3r29-r2
kernel-module-pl2303 - 2.3r29-r2
kernel-module-usbnet - 2.3r29-r2
kernel-module-usbserial - 2.3r29-r2



Relevant Pages

  • RE: configuring dial-up for extreme novices (i.e. Mom).
    ... I'm going to use userland ppp and postfix. ... > your Mom a script to run which will start fetchmail, ... Then have commands in script to kill fetchmail and user ... sudo /usr/sbin/ppp -quiet -background myisp ...
    (freebsd-questions)
  • Starting fetchmail in daemon mode from cron
    ... I'm trying to get fetchmail tweaked to poll based on usage conditions: ... running the script every minute and manually polling when appropriate ... kernel-module-ftdi-sio - 2.3r29-r2 ...
    (alt.os.linux)
  • Re: Troubles starting fetchmail from init scripts
    ... My startup script and configuration. ... # Start fetchmail for jonrysh ... echo "Configuration file not found " ...
    (Fedora)
  • Re: strange email behavior
    ... > different computer you use fetchmail to connect to the ... > poll your POP3 mailbox manually to debug your problem. ... I saw that the script was calling /etc/fetchmailrc, ... instead of my user's mbox. ...
    (RedHat)
  • Re: strange email behavior
    ... > startup script for fetchmail that might have something to do with it. ... Since running fetchmail as root is such an unbelievably bad idea that I ... the init script that you've got. ...
    (RedHat)