linux – 如何在Crontab中正确运行OfflineIMAP

发布时间:2020-05-20 发布网站:脚本之家
脚本之家收集整理的这篇文章主要介绍了linux – 如何在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 = 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

我尝试过不同变化的TTY.TTYUI,NonInteractive.Quiet和NonInteractive.Basic.无论有没有重定向,我尝试的crontab条目都会导致问题.

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

我总是得到同样该死的错误错误:没有找到可用的UI!我究竟做错了什么!?

解决方法

使用-u开关指定正确的UI
offlineimap -u Noninteractive.Quiet # right
offlineimap -u NonInteractive.Quiet # WRONG!

总结

以上是脚本之家为你收集整理的linux – 如何在Crontab中正确运行OfflineIMAP全部内容,希望文章能够帮你解决linux – 如何在Crontab中正确运行OfflineIMAP所遇到的程序开发问题。

如果觉得脚本之家网站内容还不错,欢迎将脚本之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您喜欢交流学习经验,点击链接加入脚本之家官方QQ群:1065694478