I'm not very well versed in all things launchd but I wrote this plist file that periodically runs offlineimap to fetch new mail from IMAP servers:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.dpo.offlineimap</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/offlineimap</string>
<string>-o</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>ProcessType</key>
<string>Background</string>
<key>StartInterval</key>
<integer>1800</integer>
</dict>
</plist>
The file is located in ~/Library/LaunchAgents/net.dpo.offlineimap.plist.
The issue is that the process doesn't seem to wake up when I wake the computer from sleep. Running
$ launchctl stop net.dpo.offlineimap
$ launchctl start net.dpo.offlineimap
reactivates it, but that seems to defeat the KeepAlive option.
I tried using
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<true/>
<key>NetworkState</key>
<true/>
</dict>
but I observe the same behavior. I'm on OSX 10.9. My ~/.offlineimaprc doesn't use the autorefresh option.
Is anything wrong with the plist file?
Thanks in advance!