Hi Barak, Matthias, On Tue, Nov 23, 2021 at 11:51 AM Barak A. Pearlmutter <ba...@pearlmutter.net> wrote: > I've written a unit so I can run fetchmail under systemd as a user service. > I'd suggest that the file /usr/lib/systemd/user/fetchmail.service (see > below) be included in the package. It would be best if upstream integrates it to the source code. Even if 6.4.25 is just around the corner.
> It would also make sense to describe how to actually enable it, by > putting something like the following into > /usr/share/doc/fetchmail/README.systemd: > > To run fetchmail as a systemd user service, for an individual user: > > (1) Configuration > > Set up your .fetchmailrc so that "fetchmail --nodetach" actually > fetches your mail correctly. > > (2) Tell systemd to run it as a service > > Allow daemons to keep running after you log out (optional): > $ sudo loginctl enable-linger $USERNAME > > Make the service available: > $ systemctl --user enable fetchmail.service > > Actually turn it on: > $ systemctl --user start fetchmail.service > > Monitor it, to check if it's okay: > $ systemctl --user status fetchmail.service > > Monitor it harder: > $ journalctl --user -xeu fetchmail.service This is also a good candidate for upstream. > Caveat: > > In the below fetchmail.service file, I'm not sure if the "ExecStop=" > command is a good idea. If you just leave that line out, systemd will > kill the process using its own mechanisms, which are effective but > perhaps a bit brutal. Might be more robust to just leave it out. > > It's currently set to wake up every 5min. Not sure how to make this > default nicely but still be easy to change. Perhaps some systemd > wizard can help? That's not me, but should look into it. The actual systemctl service file: > $ cat /usr/lib/systemd/user/fetchmail.service > [Unit] > Description=Fetchmail Daemon > Documentation=man:fetchmail(1) > > [Service] > ExecStart=fetchmail --nodetach --daemon 300 > ExecStop=fetchmail --quit > Restart=always > > [Install] > WantedBy=default.target Regards, Laszlo/GCS