Offlineimap succeeds at prompt but fails via cron job

Joseph LP ootput at gmail.com
Tue Nov 24 03:11:15 UTC 2009


Paul Hinze <paul.t.hinze <at> gmail.com> writes:

> Joseph LP <ootput <at> gmail.com> on 2009-11-20 at 06:55:
> > I've an issue with Offlineimap 6.2.0 on Debian Squeeze whereby the command
> > perfectly fine when launched manually at command line, but fails when run on
> > cron schedule.
>
> The error you included unfortunately doesn't make it immediately obvious where
> the problem is coming from, so it could be either dovecot or offlineimap that
> is choking there.
>
> More often than not, however, things that work in a normal environment but
> break in cron have to do with issues with the shell environment.
>
> For debugging this I usually see if the command in question works via
> `env -i $COMMAND` (start with an empty environment and run $COMMAND) and thenI
> start to look at the output of `env` run as my user and try and determine what
> environment variables might be getting relied upon.

Hi Paul, your env suggestions allowed me to see more descriptive errors.

With $ env -i offlineimap:

Thread 'Account sync ***' terminated with exception:
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.5/offlineimap/threadutil.py", line 149, in
  run
    Thread.run(self)
  File "/usr/lib/python2.5/threading.py", line 446, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/pymodules/python2.5/offlineimap/accounts.py", line 174, in
  syncrunner
    self.remoterepos =
    offlineimap.repository.Base.LoadRepository(self.getconf('remoterepository'),
    self, 'remote')
  File "/usr/lib/pymodules/python2.5/offlineimap/repository/Base.py", line 37,
  in LoadRepository
    return typemap[repostype](name, account)
  File "/usr/lib/pymodules/python2.5/offlineimap/repository/IMAP.py", line 30,
  in __init__
    self.imapserver = imapserver.ConfigedIMAPServer(self)
  File "/usr/lib/pymodules/python2.5/offlineimap/imapserver.py", line 423, in
  __init__
    password = self.repos.getpassword()
  File "/usr/lib/pymodules/python2.5/offlineimap/repository/IMAP.py", line 174,
  in getpassword
    netrcentry = netrc.netrc().authenticators(self.gethost())
  File "/usr/lib/python2.5/netrc.py", line 28, in __init__
    raise IOError("Could not find .netrc: $HOME is not set")
IOError: Could not find .netrc: $HOME is not set

No debug messages were logged for Account sync ***.

With $ env, I've noticed $HOME is not set, though issuing echo $HOME at prompt
reveals the correct path. I'm not sure how to address this issue.

My .netrc is actually a symlink to a different file (for privacy reasons, as I
host my config files publically for quick backup/restore), but making ~/.netrc
an actual file does not resolve the matter.

>
> For more strategies on getting to the bottom of this I'd take a look at someof
> the top hits on a google search for some combination of '[debug|troubleshoot]
> cron job'.
>

Will do. I appreciate your advice so far.

Regards,
Joe





More information about the OfflineIMAP-project mailing list