Talk:Getmail
getmail with systemd
The article states that cron is not in base anymore and systemd (timers) might be an option. The notice encourages a discussion, so I thought I start one. :) --BorisA (talk) 19:31, 18 November 2015 (UTC)
service for imap idle
Personally I run my main getmail with an IMAP-Idle connections, so instead of timers a normal systemd user-service is a good option, I found this blogpost to be helpful and did something similar. I have a file "~/.config/systemd/user/getmail-foo.service"
~/.config/systemd/user/foo.service
[Unit] Description=Get mails from foo After=network.target Wants=network.target [Service] ExecStart=/usr/bin/getmail --rcfile=foo.ini --idle=Inbox Restart=always [Install] WantedBy=default.target
and enabled it with
# systemctl --user enable getmail-foo.service
This way the service gets started after logging in and listens for changes in the folder "Inbox". For local imap the Unit could also set After/Wants to the service that provides imap (e.g. "dovecot.service"), which is what I do. I guess this wouldn't start dovecot if its not running, but at least it should check if dovecot is really running, but I haven't tested this yet. --BorisA (talk) 19:31, 18 November 2015 (UTC)
timer
For some less important accounts I use getmail timers to start getmail regularly like cron does. I created two files for this in ~/.config/systemd/user/
~/.config/systemd/user/getmail.service
[Unit] Description=Fetch mails After=network.target Wants=network.target [Service] Type=oneshot ExecStart=/usr/bin/getmail --rcfile=bar.ini --rcfile=baz.ini
~/.config/systemd/user/getmail.timer
[Unit] Description=Timer for getmail [Timer] OnBootSec=1min OnUnitActiveSec=15min [Install] WantedBy=timers.target
and enabled the timer with
# systemctl --user enable getmail.timer
this starts getmail for the configurations "bar.ini" and "baz.ini" 1 minute after boot and then every 15 minutes. To see if it worked and when the next run is scheduled you can list the user timers (systemctl --user list-timers
) --BorisA (talk) 19:31, 18 November 2015 (UTC)