• fetchmail and cron riddle

    From John McGrail@21:1/5 to you on Wed Dec 9 15:32:21 2015
    In comp.unix.bsd.openbsd.misc, you wrote:
    I have installed 5.8 on to laptop and added fetchmail.
    When I invoke fetchmail from the command line it just works, no hassle.
    When I put it into a crontab, in my name as /usr/local/bin/fetchmail
    it complains that there are no mailservers have been specified.
    When I add -f /home/martin/.fetchmailrc it tells me:
    /var/log/.fetchmail.pid Permission denied, obviously I dont have

    From the man page (man fetchmail):
    ...
    ~/.fetchmail.pid
    lock file to help prevent concurrent runs (non-root mode).
    ...
    /var/run/fetchmail.pid
    lock file to help prevent concurrent runs (root mode, Linux systems)

    I find it a little odd that your pid file ended up in /var/log/.fetchmail.pid.

    That aside, I'd guess that your cron job is not running as you. Are you explicitely setting the user field in the crontab entry to _you_?

    --
    ratfood@food.skaterat.net
    All foods should be removed to reply

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin Smith@21:1/5 to John McGrail on Wed Dec 9 20:08:49 2015
    On 2015-12-09, John McGrail <ratfood@food.skaterat.net> wrote:
    In comp.unix.bsd.openbsd.misc, you wrote:
    I have installed 5.8 on to laptop and added fetchmail.
    When I invoke fetchmail from the command line it just works, no hassle.
    When I put it into a crontab, in my name as /usr/local/bin/fetchmail
    it complains that there are no mailservers have been specified.
    When I add -f /home/martin/.fetchmailrc it tells me:
    /var/log/.fetchmail.pid Permission denied, obviously I dont have

    that was because I failed to alter the HOME directive

    From the man page (man fetchmail):
    ...
    ~/.fetchmail.pid
    lock file to help prevent concurrent runs (non-root mode).
    ...
    /var/run/fetchmail.pid
    lock file to help prevent concurrent runs (root mode, Linux systems)

    I find it a little odd that your pid file ended up in /var/log/.fetchmail.pid.

    That aside, I'd guess that your cron job is not running as you. Are you explicitely setting the user field in the crontab entry to _you_?

    well according to the man page you can set the user in a system crontab
    but not in a user one, any way by juggling with the HOME directive and
    changing it to /home/martin/log I have got it to work, though it still seems to be downloading twice, any ideas on that, the man page is a bit vague about it.


    --
    Martin

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin Smith@21:1/5 to All on Wed Dec 9 08:48:18 2015
    I have installed 5.8 on to laptop and added fetchmail.
    When I invoke fetchmail from the command line it just works, no hassle.
    When I put it into a crontab, in my name as /usr/local/bin/fetchmail
    it complains that there are no mailservers have been specified.
    When I add -f /home/martin/.fetchmailrc it tells me:
    /var/log/.fetchmail.pid Permission denied, obviously I dont have
    write permission there.
    So that makes me wonder where does it write its pid when I call it
    from the command line, it is still me calling it?
    Finally I tried it in a root crontab, I warns me it dangerous to
    run it as root, tells me the .fetchmailrc must be owned by me which it
    is, and then does not download any mail anyway.
    I just wondered if anyone has any ideas for a working solution
    Thanks in advance.

    --
    Martin

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From DoN. Nichols@21:1/5 to John McGrail on Thu Dec 10 02:12:31 2015
    On 2015-12-09, John McGrail <ratfood@food.skaterat.net> wrote:
    In comp.unix.bsd.openbsd.misc, you wrote:
    I have installed 5.8 on to laptop and added fetchmail.
    When I invoke fetchmail from the command line it just works, no hassle.
    When I put it into a crontab, in my name as /usr/local/bin/fetchmail
    it complains that there are no mailservers have been specified.
    When I add -f /home/martin/.fetchmailrc it tells me:
    /var/log/.fetchmail.pid Permission denied, obviously I dont have

    From the man page (man fetchmail):
    ...
    ~/.fetchmail.pid
    lock file to help prevent concurrent runs (non-root mode).
    ...
    /var/run/fetchmail.pid
    lock file to help prevent concurrent runs (root mode, Linux systems)

    I find it a little odd that your pid file ended up in /var/log/.fetchmail.pid.

    That aside, I'd guess that your cron job is not running as you. Are you explicitely setting the user field in the crontab entry to _you_?

    Another thought -- cron tends to run with a very restricted
    "PATH" environment variable. So any scripts either need to set the PATH
    at the start, or include the full path to anything outside of what the
    current PATH used by cron is. Running "strings `which cron` | grep PATH"
    gives this:

    ====================================================================== PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin
    PATH
    PATH=
    ======================================================================

    on a 5.5 system.

    Anything out of the PATH which you find on your 5.8 system will
    not be found unless you do one of the two work-arounds above. I tend to
    prefer the explicit path for each command in something like:

    GREP=/usr/bin/grep

    and invoke it as:

    ${GREP}

    except that GREP is where it will be found anyway. But check everything invoked from scripts involved.

    Good Luck,
    DoN.

    --
    Remove oil spill source from e-mail
    Email: <BPdnicholsBP@d-and-d.com> | (KV4PH) Voice (all times): (703) 938-4564
    (too) near Washington D.C. | http://www.d-and-d.com/dnichols/DoN.html
    --- Black Holes are where God is dividing by zero ---

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)