Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: dovecot restart



On Sun, 13 Sep 2026, Thomas Klausner wrote:

I'm rotating my SSL Certs with certbot, also for postfix and dovecot.
Since certbot has no retart plugins for postfix and dovecot, I have a
weekly cronjob that runs '/etc/rc.d/postfix restart' and another one
for '/etc/rc.d/dovecot restart'.

The postfix cronjob sends email immediately; the dovecot one only
after a week, I think when the next dovecot restart cronjob runs.
When I interactively run '/etc/rc.d/dovecot restart' it finishes
quickly.

Does anyone have an idea where that 1-week-delay could come from?


cron is still waiting for output from dovecot:

1. dovecot doesn't dup2() its STDERR_FILENO[1]--prolly to spew out error msgs.

2. when cron runs a crontab command, it dup2(STDOUT, STDERR)s the cmds stdout
   and stderr.

3. then it reads from this combined output and write()s this to sendmail's
   stdin.

4. all this works if either a) the program dies (ie. is not a daemon) so that
   cron can close sendmail's stdin.; or b) the daemon itself closes its stderr
   so an EOF can be generated when stdout is exhausted.

5. neither a) nor b) are satisfied in this case, so cron is still waiting for
   output which'll never arrive.

6. a week later, `service dovecot restart' kills the still running dovecot
   so cron can now "complete" the job and generate the email.

You should notify upstream about this oddball case.

You can try this yourself on the command line w/o running cron:

```
/etc/rc.d/dovecot 2>&1 | tee /dev/null
````

then check dovecot's open FDs using fstat.

-RVP

[1]: https://github.com/dovecot/core/blob/main/src/master/main.c#L931


Home | Main Index | Thread Index | Old Index