ubuntu postfix timezone change
Asked Answered
D

3

5

I met this weird problem, and I tried a whole afternoon to solve this, with all the methods I found from google, but till now, nothing seems to be worked.

My ubuntu server's (10.04 LTS) timezone is Europe/Helsinki, it's correct (when I run "date" command, the result shows the right time). But my postfix seems still using UTC timezone, because all the time in /var/log/mail.log is 3 hours earlier than my current time.

I've also copied the /etc/localtime to /var/spool/postfix/etc/localtime, but nothing helps. (cp /usr/share/zoneinfo/Europe/Helsinki /var/spool/postfix/etc/localtim also not work).

I also tried to run dpkg-reconfigure tzdata, also not work, system time always correct, but only mail.log got wrong.

Could anyone give me some suggestion ?

*I have restarted postfix everytime I tried to make some change.

Drawshave answered 14/6, 2011 at 12:39 Comment(2)
Seems to me that Postfix records dates in UTC because that's the most reasonable way to be sure of times emails were sent and received across the many time zones.Irritative
hmmm, but there must be some way to force it to use another timezone isn't it ?Drawshave
I
7

Copying the timezone (/etc/localtime) into Postfix's chroot should do the trick, but there are a couple assumptions:

  1. Is your /etc/timezone file set correctly as well? It should probably only contain the line Europe/Helsink. (Note that you can probably set all the timezone stuff correctly with the command sudo dpkg-reconfigure tzdata.)

  2. If Postfix is using syslogd for logging, then that may be what is recording logs in UTC. You might consider changing to syslogd-ng (or similar) which supports multiple timezones.

  3. Are you sure that /var/spool/postfix is the chroot that Postfix is using? If that isn't the root of your Postfix jail, there probably won't be all the other config files there.; you can look for the chroot option in the master.cf file, or here's another way to check. In any case, you want the /etc/localtime file in the etc folder that Postfix is using.

  4. Just in case, be sure that it is a "real" timezone file you're copying in, not a symbolic link (from ln -s targetfilename linkfilename). You can use the command file /etc/localtime to test; if it tells you it's timezone data, go ahead and copy it to Postfix's chroot; if it tells you it's a symlink, then you want to copy the original /usr/share/zoneinfo/Europe/Helsinki.

Irritative answered 15/6, 2011 at 12:51 Comment(1)
How can I tell if postfix is using syslogd for logging?Avera
S
7

After you changing your timezone, you should restart your syslogd with:

 sudo service rsyslog restart

Because postfix usually use syslogd for logging.

Symbolics answered 13/3, 2019 at 11:28 Comment(0)
C
0

Not exactly ubuntu but because this question is in the top of the search results: For me the problem was in rsyslog timezone. To fix:

vim /etc/sysconfig/clock 
ZONE="America/New_York"     # or your timezone, of course
systemctl restart rsyslog
#  or
/etc/init.d/rsyslog restart

Then restart postfix.

Thanks to this post

Chilt answered 9/2, 2018 at 9:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.