From: Vikas R. <vik...@gm...> - 2022-07-14 21:17:35
|
I am somehow unable to get systemd to run mbsync regularly. I have created the following files and enabled them. Would appreciate any pointers about what might be wrong here. VR ----- *~/.config/systemd/user/mbsync.service:* [Unit] Description=Mbsync synchronization service [Service] Type=oneshot ExecStart= /bin/sh -c "/usr/local/bin/mbsync -V daily" ExecStartPost=/bin/sh -c 'notmuch new && afew -t -n && afew --move-mails -v && echo "notmuch `date`" >> ~/tmp/maillog.log' [Install] WantedBy=default.target *~/.config/systemd/user/mbsync.timer:* [Unit] Description=Mysync synchronization timer [Timer] OnBootSec=2m OnCalendar=*:00/2 Unit=mbsync.service [Install] WantedBy=timers.target |
From: Oswald B. <osw...@gm...> - 2022-07-15 06:39:37
|
On Fri, Jul 15, 2022 at 02:47:17AM +0530, Vikas Rawal wrote: >I am somehow unable to get systemd to run mbsync regularly. I have created >the following files and enabled them. > >Would appreciate any pointers about what might be wrong here. > did you run `systemctl status` on mbsync.service and mbsync.timer? i can't see anything really wrong, just two observations: >*~/.config/systemd/user/mbsync.service:* > >[Unit] >Description=Mbsync synchronization service > >[Service] >Type=oneshot >ExecStart= /bin/sh -c "/usr/local/bin/mbsync -V daily" there is no need to run this through a shell. >ExecStartPost=/bin/sh -c 'notmuch new && afew -t -n && afew --move-mails -v && echo "notmuch `date`" >> ~/tmp/maillog.log' > >[Install] >WantedBy=default.target > this doesn't look right. >*~/.config/systemd/user/mbsync.timer:* > >[Unit] >Description=Mysync synchronization timer > >[Timer] >OnBootSec=2m >OnCalendar=*:00/2 >Unit=mbsync.service > >[Install] >WantedBy=timers.target |
From: Max G. <ash...@gm...> - 2022-07-15 08:06:20
|
Check the status for both the timer and the service, but on the top of my head: > [Service] > ... > ExecStartPost=/bin/sh -c 'notmuch new && afew -t -n && afew --move-mails -v > && echo "notmuch `date`" >> ~/tmp/maillog.log' I had problems in the past when breaking Exec lines on several lines, might be the reason it does not work. > [Timer] > OnBootSec=2m > OnCalendar=*:00/2 That does not seem to conform to the format in systemd.time(7) ? You can just use 'daily' (inferring from your channel name) > Unit=mbsync.service That's not needed, the default is to trigger the service with matching unsuffixed name -- Max Gautier |
From: Vikas R. <vik...@gm...> - 2022-07-21 16:20:25
|
I have modified the scripts slightly based on recommendations on this thread. But this still does not work. I am just looking for mbsync to run every two minutes. What do most people use? It is crazy that something so obvious should be so difficult to get right. Vikas --- # mbsync.service [Unit] Description=Mbsync synchronization service [Service] Type=oneshot ExecStart= /usr/local/bin/mbsync -V daily #ExecStartPost=/bin/sh -c '/usr/bin/notmuch new && /home/vikas/bin/afew -t -n && /home/vikas/bin/afew --move-mails -v && echo "notmuch `date`" >> /home/vikas/bin/maillog.log' [Install] WantedBy=default.target #mbsync.timer [Unit] Description=Mysync synchronization timer [Timer] OnBootSec=2m OnUnitActiveSec=2m Unit=mbsync.service [Install] WantedBy=timers.target On Fri, 15 Jul 2022 at 13:36, Max Gautier <ash...@gm...> wrote: > Check the status for both the timer and the service, but on the top of > my head: > > [Service] > > ... > > ExecStartPost=/bin/sh -c 'notmuch new && afew -t -n && afew --move-mails > -v > > && echo "notmuch `date`" >> ~/tmp/maillog.log' > > I had problems in the past when breaking Exec lines on several lines, > might be the reason it does not work. > > > [Timer] > > OnBootSec=2m > > OnCalendar=*:00/2 > That does not seem to conform to the format in systemd.time(7) ? You can > just use 'daily' (inferring from your channel name) > > > Unit=mbsync.service > > That's not needed, the default is to trigger the service with matching > unsuffixed name > > -- > Max Gautier > |
From: Simão A. <sim...@po...> - 2022-07-21 17:51:38
|
On 2022-07-21 21:50:04, Vikas Rawal wrote: > I have modified the scripts slightly based on recommendations on this > thread. But this still does not work. I am just looking for mbsync to run > every two minutes. What do most people use? I configured a hotkey on "neomutt", I don't need to check the mail if I'm not reading it. Make sure you are defining this on your per-user systemd configuration. That's in `~/.config/systemd/user/`, or `/etc/systemd/user`. |
From: Max G. <ash...@gm...> - 2022-07-22 06:49:24
|
> I have modified the scripts slightly based on recommendations on this > thread. But this still does not work. I am just looking for mbsync to run > every two minutes. What do most people use? I switched recently to initial sync on starting (but maybe I'll change that to start to first time mutt is opened) then watching mailboxes with goimapnotifiy (ordering is done by systemd): # override for goimapnotify@.service [Install] RequiredBy=mail-sync@.target WantedBy= [Unit] After=mbsync@%i.service network-online.target PartOf=mail-sync@%i.target [Service] SyslogIdentifier=goimapnotify-%i Slice=app-mailsync-%i.slice # goimapnotify config { "host": "imap.gmail.com", "tls": true, "port": 993, "tlsOptions": { "rejectUnauthorized": true }, "username": "user", "passwordCmd": "oauth2get gmail account", "xoauth2": true, "onNewMail": "systemctl start --user mbsync@account", "boxes": [ "INBOX" ] } # mbsync@.service [Unit] Wants=network-online.target After=network-online.target PartOf=mail-sync@%i.target [Service] Type=oneshot ExecStart=/usr/bin/mbsync -c %E/mbsync/config -V %i Restart=on-failure RestartSec=30 SyslogIdentifier=mbsync-%i Slice=app-mailsync-%i.slice [Install] RequiredBy=mail-sync@.target -- Max Gautier |
From: Johannes K. <ma...@oj...> - 2022-07-21 17:54:40
|
On 21.07.22 18:20 Vikas Rawal wrote: > I have modified the scripts slightly based on recommendations on this > thread. But this still does not work. I am just looking for mbsync to run > every two minutes. What do most people use? > > It is crazy that something so obvious should be so difficult to get right. Please run the following commands: systemctl --user status mbsync.service systemctl --user status mbsync.timer Did you run "systemctl --user daemon-reload" after the modifications? Did you enable the timer? Did you start the timer? ... Kind Regards, Johannes |
From: Vikas R. <vik...@gm...> - 2022-07-22 00:28:45
|
I think it is working at the moment. But it stops every now and then. As you would see below, mbsync.service also ends with an error. There is no such error when I run mbsync -V daily myself. Is this error makes systemd stop running it repeatedly? > Please run the following commands: > > systemctl --user status mbsync.service > × mbsync.service - Mbsync synchronization service Loaded: loaded (/home/xxxxx/.config/systemd/user/mbsync.service; disabled; vendor preset: enabled) Active: failed (Result: exit-code) since Fri 2022-07-22 05:55:52 IST; 9s ago TriggeredBy: ● mbsync.timer Process: 2148631 ExecStart=/usr/local/bin/mbsync -V daily (code=exited, status=1/FAILURE) Main PID: 2148631 (code=exited, status=1/FAILURE) CPU: 6.305s Jul 22 05:55:50 jhumritalaiya mbsync[2148631]: Opening near side box Trash... Jul 22 05:55:51 jhumritalaiya mbsync[2148631]: Loading far side box... Jul 22 05:55:51 jhumritalaiya mbsync[2148631]: far side: 0 messages, 0 recent Jul 22 05:55:51 jhumritalaiya mbsync[2148631]: Loading near side box... Jul 22 05:55:51 jhumritalaiya mbsync[2148631]: near side: 0 messages, 0 recent Jul 22 05:55:51 jhumritalaiya mbsync[2148631]: Synchronizing... Jul 22 05:55:52 jhumritalaiya systemd[996]: mbsync.service: Main process exited, code=exited, status=1/FAILURE Jul 22 05:55:52 jhumritalaiya systemd[996]: mbsync.service: Failed with result 'exit-code'. Jul 22 05:55:52 jhumritalaiya systemd[996]: Failed to start Mbsync synchronization service. Jul 22 05:55:52 jhumritalaiya systemd[996]: mbsync.service: Consumed 6.305s CPU time. systemctl --user status mbsync.timer > > ● mbsync.timer - Mysync synchronization timer Loaded: loaded (/home/xxxxx/.config/systemd/user/mbsync.timer; enabled; vendor preset: enabled) Active: active (waiting) since Thu 2022-07-21 19:32:21 IST; 10h ago Until: Thu 2022-07-21 19:32:21 IST; 10h ago Trigger: Fri 2022-07-22 05:52:10 IST; 659ms left Triggers: ● mbsync.service Jul 21 19:32:21 jhumritalaiya systemd[996]: Stopping Mysync synchronization timer... Jul 21 19:32:21 jhumritalaiya systemd[996]: Started Mysync synchronization timer. > > Did you run "systemctl --user daemon-reload" after the modifications? > Yes > Did you enable the timer? > Yes > Did you start the timer? > Yes V. > > |
From: Johannes K. <ma...@oj...> - 2022-07-23 10:39:08
Attachments:
OpenPGP_signature
|
On 22.07.22 02:28 Vikas Rawal wrote: > I think it is working at the moment. But it stops every now and then. As > you would see below, mbsync.service also ends with an error. There is no > such error when I run mbsync -V daily myself. Is this error makes systemd > stop running it repeatedly? In addition to what Oswald pointed out, I would try to run the timer with -V and maybe some of the -D options, so you at least get more information on what is happening. Johannes |
From: Oswald B. <osw...@gm...> - 2022-07-22 05:19:44
|
On Fri, Jul 22, 2022 at 05:58:26AM +0530, Vikas Rawal wrote: >I think it is working at the moment. But it stops every now and then. As >you would see below, mbsync.service also ends with an error. There is no >such error when I run mbsync -V daily myself. > the error is certainly stochastic, so it's more likely to occur when you auto-poll often than during a few manual runs. the fact that the failure is silent is obviously an mbsync bug. i recommend that you use a build from git master - it has more reliable error reporting. it also has additional exit codes to let you know whether running the post-exec action makes sense. >Is this error makes systemd stop running it repeatedly? > i guess? systemd has protection mechanisms against error floods. you can configure the exact behavior. |
From: Vikas R. <vik...@gm...> - 2022-07-24 03:05:16
|
> > I think it is working at the moment. But it stops every now and then. As > > you would see below, mbsync.service also ends with an error. There is no > > such error when I run mbsync -V daily myself. > > > the error is certainly stochastic, so it's more likely to occur when you > auto-poll often than during a few manual runs. I am afraid I don't understand what you mean by the error being stochastic. But it seems to never happen when I run mbsync manually and almost always be the case when it is run through systemd. > the fact that the failure is silent is obviously an mbsync bug. i recommend > that you use a build from git master - it has more reliable error reporting. > it also has additional exit codes to let you know whether running the > post-exec action makes sense. I have built isync from git master: mbsync -v gives me: isync 1.5.0 But I still see the same message in systemd logs. mbsync.service: Failed with result 'exit-code'. Failed to start Mbsync synchronization service What should I do for more verbose error reporting? > > Is this error makes systemd stop running it repeatedly? > > > i guess? systemd has protection mechanisms against error floods. you can > configure the exact behavior. Can you kindly point to how? Is there a way of telling systemd to just silently ignore these errors? Thanks very much. V. |
From: Vikas R. <vik...@gm...> - 2022-07-24 03:27:06
|
> > > > > i guess? systemd has protection mechanisms against error floods. you can > > configure the exact behavior. > > Can you kindly point to how? Is there a way of telling systemd to just > silently ignore these errors? > > This seems to make systemd ignore the errors: https://stackoverflow.com/a/71770918 Let me see if this helps. |
From: Oswald B. <osw...@gm...> - 2022-07-24 05:59:59
|
On Sun, Jul 24, 2022 at 08:33:03AM +0530, Vikas Rawal wrote: >What should I do for more verbose error reporting? > as johannes already suggested, add the -D option. >> systemd has protection mechanisms against error floods. you can >> configure the exact behavior. > >Can you kindly point to how? Is there a way of telling systemd to just silently ignore these errors? > as i already implied, yes, there is. it's all in https://www.freedesktop.org/software/systemd/man/systemd.service.html# and related pages. |