如何在 Crontab 中正确运行 OfflineIMAP

son*_*i2f 6 linux imap cron

安装了 Fedora。

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

从 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.
Run Code Online (Sandbox Code Playgroud)

而且,瞧,每次我运行 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 = username@gmail.com
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 
Run Code Online (Sandbox Code Playgroud)

我已经尝试过TTY.TTYUINonInteractive.Quiet并且NonInteractive.Basic有不同的变化。无论是否有重定向,我尝试的 crontab 条目都会导致问题。

$ crontab -l | awk ' { print F "> " $0; print ""; }'
*/5 * * * * offlineimap >> ~/mail/logs/offlineimap.log 2>&1
*/5 * * * * offlineimap
Run Code Online (Sandbox Code Playgroud)

我总是得到同样的该死的错误错误:找不到可用的用户界面!. 我究竟做错了什么!?

小智 11

如果您使用 6.3+ 版本的离线地图,请指定:

offlineimap -u quiet
Run Code Online (Sandbox Code Playgroud)

我知道 OP 指定的 6.2 版,但是搜索 ServerFault 并遇到上述答案的人可能不知道 ui 标志已更改。


jam*_*spo 9

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

offlineimap -u Noninteractive.Quiet # right
offlineimap -u NonInteractive.Quiet # WRONG!
Run Code Online (Sandbox Code Playgroud)

  • 所以我想在对你生气之后赎回自己。你是对的,我错了,在大惊小怪了很长一段时间后,我是个大混蛋。事实证明 [某些版本的 offlineimap 没有忽略 UI 参数中的大小写,并且文档中的版本本身是错误的](http://www.mail-archive.com/debian-qa-packages@lists.debian。 org/msg33038.html)。我很抱歉成为那个人。我想给你点赞,但它被锁定了一段时间。对不起。 (2认同)