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.

JuLy
  • 483
  • 2
  • 5
  • 12
  • 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. – ewall Jun 14 '11 at 13:01
  • hmmm, but there must be some way to force it to use another timezone isn't it ? – JuLy Jun 15 '11 at 04:42

3 Answers3

7

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

 sudo service rsyslog restart

Because postfix usually use syslogd for logging.

András Pál
  • 96
  • 1
  • 4
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.

ewall
  • 27,179
  • 15
  • 70
  • 84
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

Putnik
  • 5,925
  • 7
  • 38
  • 58