日志文件的日期和时间不同于 `date`、`timezone` 等

mja*_*ews 4 server time log timezone

在 Ubuntu 14.04 vps 上,我的时区设置为 UTC/GMT。

root@Ubuntu:/# date 
Fri Mar 11 13:36:56 GMT 2016

root@Ubuntu:/# cat /etc/timezone 
Europe/London

root@Ubuntu:/# ls -l /etc/localtime 
lrwxrwxrwx 1 root root 33 Mar 11 13:20 /etc/localtime -> /usr/share/zoneinfo/Europe/London
Run Code Online (Sandbox Code Playgroud)

但是,我在 /var/log 中的日志文件都提前了 9 小时(韩国时间?)。例如

root@Ubuntu:/# tail -3 /var/log/auth.log.1

Mar 11 22:27:05 Ubuntu sshd[18170]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=211.99.249.89 
Mar 11 22:27:07 Ubuntu sshd[18170]: Failed password for invalid user cstrike from 211.99.249.89 port 38066 ssh2
Mar 11 22:27:07 Ubuntu sshd[18170]: Connection closed by 211.99.249.89 [preauth]
Run Code Online (Sandbox Code Playgroud)

即使在 aservice rsyslog restart和之后情况仍然如此dpkg-reconfigure tzdata。

如何在同一时区获取所有内容?

小智 9

我遇到了同样的问题,dpkg-reconfigure tzdata并service rsyslog restart在 14.04 服务器上连续发出命令。然后我在查看auth.log时启动了 ssh 连接

tail -f /var/log/auth.log
Run Code Online (Sandbox Code Playgroud)

从那时起的日志消息是正确的,如此代码段所示

Aug 16 09:02:40 myhost sshd[11913]: Accepted publickey ...
Aug 16 09:02:40 myhost sshd[11913]: pam_unix(sshd:session): opened ...
Aug 16 09:02:43 myhost sshd[11913]: pam_unix(sshd:session): closed ...
Aug 16 15:04:45 myhost sshd[12019]: Accepted publickey .... 
Aug 16 15:04:45 myhost sshd[12019]: pam_unix(sshd:session): opened ...
Aug 16 15:05:11 myhost sshd[12019]: pam_unix(sshd:session): closed ...
Run Code Online (Sandbox Code Playgroud)

我看到你做了auth.log.1(一个旧的日志文件)的尾巴。进行时区更改不会追溯修改现有日志文件。这可能是问题吗?

  • `service rsyslog restart` 拯救我的一天 (3认同)