Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ubuntu postfix timezone change

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.

like image 480
JuLy Avatar asked Jun 14 '11 12:06

JuLy


People also ask

How do I change universal time in Ubuntu?

To do so, open Terminal or your command-line interface (CLI) and run the tzselect command. Then, specify the desired timezone and press Enter. One of the best methods to permanently change the timezone on Ubuntu is using the timedatectl command.


2 Answers

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.

like image 160
ewall Avatar answered Oct 05 '22 17:10

ewall


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

 sudo service rsyslog restart

Because postfix usually use syslogd for logging.

like image 31
András Pál Avatar answered Oct 05 '22 16:10

András Pál