From: Peter P. <ro...@ri...> - 2022-01-23 19:11:34
|
On Sun, Jan 23, 2022 at 01:35:52PM -0500, Joe Acquisto-j4 wrote: > > On Thu, Jan 20, 2022 at 11:34:26AM +0200, Peter Pentchev wrote: > > [snip] > >> directory if necessary). Something like this works for me (note that > >> I do not have a logfile directive in my fetchmail config file, so > >> it will send its output to the standard output stream by default): > >> > >> [roam@straylight ~]$ cat ~/.config/systemd/user/fetchmail.service > >> [Unit] > >> Description=Run fetchmail in daemon mode. > >> Documentation=man:fetchmail(1) > >> After=network-online.target > >> Wants=network-online.target > >> > >> [Service] > >> Type=simple > >> ExecStartPre=-fetchmail -ve200 > >> ExecStart=fetchmail -ve25 -Nd120 > >> ExecStop=fetchmail --quit > >> KillMode=process > > > > ...and of course, I forgot two lines that are kind of important: > > > > [Install] > > WantedBy=default.target > > > > G'luck, > > Peter > > > > -- > > Thanks to all. > > This is how I achieved success (getting Fetchmail to start and stop in systemd world that is): It's great that you got it running! Congratulations! (yes, I know that fighting with systemd service and unit definition files for the first time... or sometimes even for the fifteenth time... may be, um, exhausting. There is some logic to them, but it takes a while to get used to it) If I may make a couple of comments to what you showed below... > [Unit] > Description=remote-mail retrieval utility runin daaemon mode A couple of typos there ("runin", "daaemon"), but I guess they won't affect the operation of the service :) > After=network.target > Wants=network.target > > [Service] > Type=simple > EnvironmentFile=/root/.fetchmailrc Hm. This one looks a bit weird to me. I don't think that your .fetchmailrc file is indeed in the "variable=value" format that systemd would expect for a file to read environment variables from. Also, I don't think that your .fetchmailrc file even contains environment variable settings... Does it work if you remove this line? If so, then I think you may want to remove it. > #User=fetchmail > #ExecStart=/usr/lib/fetchmail-systemd-exec > ExecStart=/usr/local/bin/fetchmail -v > #-Nd120 This will only work if your .fetchmailrc file already contains a "set daemon ..." line and also a "nodetach" line. Otherwise, systemd will be kind of surprised when fetchmail creates a separate daemon process in the background and the fetchmail process that systemd started decides to exit since it has done its part of the work (started the daemon process in the background). If your .fetchmailrc file has the "set daemon" and "nodetach" lines, then yeah, this will work. I personally prefer to keep those options out of the configuration file so that I may invoke fetchmail by hand sometimes to fetch a couple of messages and exit, but that's me. If you decide to remove them from your configuration file, then you'd have to pass them here (as I did with the -N and -d120 command-line parameters). > ExecStop=/usr/local/bin/fetchmail -q > KillMode=process > #RestartSec=1 > > [Install] > WantedBy=multi-user.target > --------------------------------------------- > > Thanks again to all. Glad to have been of assistance! Of course, feel free to come back with any further questions or issues that you may have with running fetchmail under systemd (in case somebody objects to discussing such topics on this list, personal e-mail is also fine). G'luck, Peter -- Peter Pentchev ro...@ri... ro...@de... pp...@st... PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13 |