Sunday 31 August 2008

Dovecot terminates unexpectedly

Recently my dovecot IMAP server died regularly. In my log files I found the following message:
...
dovecot: 2008-08-31 09:12:50 Fatal: Time just moved backwards by 11 seconds. This might cause a lot of problems, so I'll just kill myself now. http://wiki.dovecot.org/TimeMovedBackwards
...
The wiki describes the cause - the clock of my server is not in sync - but does not offer much of help. Usage of ntp is suggested.

Openntpd syncs the system clock but does not slow it down (effectively causing the same problem). ntp offers to slow down the clock with side effects to database and CMS.

Examination of the logfile reveals that webmin runs a time sync just before dovecots unnatural death. OK, here's the cause.
...
Aug 31 09:13:01 myserver /USR/SBIN/CRON[12345]: (root) CMD (/etc/webmin/time/sync.pl)
dovecot: 2008-08-31 09:12:50 Fatal: Time just moved backwards by 11 seconds. This might cause a lot of problems, so I'll just kill myself now. http://wiki.dovecot.org/TimeMovedBackwards
...
Restarting dovecot right after the time sync will solve the problem. You can do that from the webmin user interface:
System/Scheduled Cron Job/Create a new scheduled cron job
enter
/etc/init.d/dovecot restart
select time right after /etc/webmin/time/sync.pl
and you are done.