ubuntu postfix时区更改
我遇到了这个奇怪的问题,我尝试了一整个下午来解决这个问题,用了我从google找到的所有方法,但到目前为止,似乎没有任何效果。
我的 ubuntu 服务器(10.04 LTS)的时区是 Europe/Helsinki,它是正确的(当我运行“date”命令时,结果显示正确的时间)。但我的 postfix 似乎仍在使用 UTC 时区,因为 /var/log/mail.log 中的所有时间都比我当前时间早 3 小时。
我还将 /etc/localtime 复制到 /var/spool/postfix/etc/localtime ,但没有任何帮助。 (cp /usr/share/zoneinfo/Europe/Helsinki /var/spool/postfix/etc/localtim 也不起作用)。
我也尝试运行 dpkg-reconfigure tzdata,也不起作用,系统时间总是正确的,但只有 mail.log 出错了。
有人能给我一些建议吗?
*每次我尝试进行一些更改时,我都会重新启动 postfix。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将时区 (/etc/localtime) 复制到 Postfix 的 chroot 中应该可以解决问题,但有几个假设:
您的 /etc/timezone 文件设置也正确吗?它可能应该只包含
Europe/Helsink
行。 (请注意,您可以使用命令sudo dpkg-reconfigure tzdata
正确设置所有时区内容。)如果 Postfix 使用 syslogd 进行日志记录,那么这可能就是以 UTC 格式记录日志的内容。您可以考虑更改为支持多个时区的syslogd-ng(或类似) .
您确定 /var/spool/postfix 是 Postfix 使用的 chroot 吗?如果那不是你的 Postfix 监狱的根目录,那里可能不会有所有其他配置文件。您可以在master.cf文件中查找chroot选项,或者这里的另一种检查方法。无论如何,您都需要 Postfix 使用的 etc 文件夹中的 /etc/localtime 文件。
以防万一,请确保您要复制的“真实”时区文件,而不是符号链接(来自
ln -s targetfilename linkfilename
)。可以使用命令file /etc/localtime
来测试;如果它告诉你这是时区数据,请继续将其复制到 Postfix 的 chroot;如果它告诉您这是一个符号链接,那么您需要复制原始的/usr/share/zoneinfo/Europe/Helsinki
。Copying the timezone (/etc/localtime) into Postfix's chroot should do the trick, but there are a couple assumptions:
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 commandsudo dpkg-reconfigure tzdata
.)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.
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.
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 commandfile /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
.更改时区后,您应该使用以下命令重新启动 syslogd:
因为 postfix 通常使用 syslogd 进行日志记录。
After you changing your timezone, you should restart your syslogd with:
Because postfix usually use syslogd for logging.
不完全是 ubuntu,而是因为这个问题位于搜索结果的顶部:
对我来说,问题出在 rsyslog 时区。修复方法:
然后重新启动 postfix。
感谢这篇文章
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:
Then restart postfix.
Thanks to this post