如何在 Crontab 中正确运行 OfflineIMAP

如何在 Crontab 中正确运行 OfflineIMAP

已安装 Fedora。

# cat /etc/redhat_release | awk ' { print F "> " $0; print ""; }'
Fedora release 14 (Laughlin)

从 yum 安装了 offlineimap,因为我最近很懒。

# yum info offlineimap | awk ' { print F "> " $0; print ""; }'
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Installed Packages

Name        : offlineimap
Arch        : noarch
Version     : 6.2.0
Release     : 2.fc14
Size        : 611 k
Repo        : installed
From repo   : fedora
Summary     : Powerful IMAP/Maildir synchronization and reader support
URL         : http://software.complete.org/offlineimap/
License     : GPLv2+
Description : OfflineIMAP is a tool to simplify your e-mail reading. With
            : OfflineIMAP, you can read the same mailbox from multiple
            : computers.  You get a current copy of your messages on each
            : computer, and changes you make one place will be visible on all
            : other systems. For instance, you can delete a message on your home
            : computer, and it will appear deleted on your work computer as
            : well. OfflineIMAP is also useful if you want to use a mail reader
            : that does not have IMAP support, has poor IMAP support, or does
            : not provide disconnected operation.

瞧,每次我运行 offlineimap 并尝试在 crontab 中重定向输出时,它都不起作用。下面是我的.offlineimaprc

[general]
ui = TTY.TTYUI
accounts = Personal, Work
maxsyncaccounts = 3

[Account Personal]
localrepository = Local.Personal
remoterepository = Remote.Personal

[Account Work]
localrepository = Local.Work
remoterepository = Remote.Work

[Repository Local.Personal]
type = Maildir
localfolders = ~/mail/gmail

[Repository Local.Work]
type = Maildir
localfolders = ~/mail/companymail

[Repository Remote.Personal]
type = IMAP
remotehost = imap.gmail.com
remoteuser = [email protected]
remotepass = password
ssl = yes
maxconnections = 4 

# Otherwise "deleting" a message will just remove any labels and 
# retain the message in the All Mail folder.
realdelete = no

[Repository Remote.Work]
type = IMAP
remotehost = server.company.tld
remoteuser = username
remotepass = password
ssl = yes
maxconnections = 4 

我尝试过TTY.TTYUINonInteractive.QuietNonInteractive.Basic尝试了不同的变体。无论是否使用重定向,我尝试的 crontab 条目都会出现问题。

$ crontab -l | awk ' { print F "> " $0; print ""; }'
*/5 * * * * offlineimap >> ~/mail/logs/offlineimap.log 2>&1
*/5 * * * * offlineimap

我总是得到同样的错误错误:未发现可用的 UI!。 我究竟做错了什么!?

答案1

使用 -u 开关指定正确的 UI

offlineimap -u Noninteractive.Quiet # right
offlineimap -u NonInteractive.Quiet # WRONG!

答案2

如果您使用 6.3+ 版本的 offlineimap,请指定:

offlineimap -u quiet

我知道 OP 指定了版本 6.2,但是搜索 ServerFault 并遇到上述答案的人可能没有意识到 ui 标志已经改变。

相关内容