Linux 服务器历史记录不一致

Linux 服务器历史记录不一致

我们在生产环境中使用 Cent OS 机器,有时 Web 应用程序 [Jboss] 会给出小时后的时间戳而不是当前时间。即使在服务器历史记录中也有不一致的时间戳。任何人都可以帮我解决这个问题。

我们已经验证了系统日期及其正确性,网络服务器日志也写入了系统日期。但只有访问日志写入的时间戳不一致。

### server history : ###


     5471  21/06/17 09:55:11 ls -ltr
     5472  21/06/17 09:55:41 clear
     5473  21/06/17 09:55:42 ls -ltr
     5474  21/06/17 09:55:46 clear
     5475  21/06/17 09:55:50 cd ../../bin/
     5476  21/06/17 09:55:53 sh standalone.sh &
     5477  21/06/17 07:54:53 cd /logdata/
     5478  21/06/17 07:54:55 ls -ltr
     5479  21/06/17 07:54:56 clear
     5480  21/06/17 07:55:04 java DateTime
     5481  21/06/17 08:01:34 date
     5482  21/06/17 08:01:56 clear
     5483  21/06/17 08:01:58 date
     5484  21/06/17 08:03:11 cat /etc/localtime
     5485  21/06/17 08:03:22 date
     5486  21/06/17 08:32:27 jps
     5487  21/06/17 08:32:50 ps -ef|egrep "23670|24538|2420724207"
     5488  21/06/17 08:32:58 ps -ef|egrep "23670|24538|24207"
     5489  21/06/17 09:42:54 jps
     5490  21/06/17 09:43:01 date
     5491  21/06/17 09:43:09 ntpq -l
     5492  21/06/17 09:43:14 ntpq -p
     5493  21/06/17 09:44:08 date
     5494  21/06/17 09:46:09 jps
     5495  21/06/17 09:46:36 pwdx 24538
     5496  21/06/17 09:46:48 pwdx 24207
     5506  21/06/17 09:49:49 pwdx 24538 24207
     5507  21/06/17 08:24:45 jps
     5508  21/06/17 08:24:49 date
     5509  21/06/17 08:24:55 clear
     5510  21/06/17 08:25:50 ifconfig
     5511  21/06/17 08:38:49 clear


###JBOSS Access Log :###

21/Jun/2017:08:46:12 +0100 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-40
21/Jun/2017:08:46:12 +0100 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-40
21/Jun/2017:07:47:58 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-41
21/Jun/2017:07:47:58 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-41
21/Jun/2017:07:47:58 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-41
21/Jun/2017:07:47:58 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-41
21/Jun/2017:08:52:22 +0100 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-53
21/Jun/2017:08:52:22 +0100 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-53
21/Jun/2017:08:52:22 +0100 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-5

答案1

.bash_history 很简单。该文件不会逐行写入。它通常在 shell 关闭/退出时附加。在多用户系统上,这可能会根据多人登录和退出的时间创建显示的条件。例如,假设您于 08:00 通过 ssh 登录。在 08:00 到 08:05 之间运行了一些命令,但没有注销。然后,您在 09:00 打开另一个 ssh 会话并运行一些命令,并在几分钟后注销。稍后您会发现有一个会话打开(您在 08:00 开始的会话)并退出。 .bash_history 文件会将早期会话的历史记录(包含 08:00-08:05 之间的命令)附加到 09:00 打开的会话退出时附加的命令。我一直在具有共享/应用程序帐户的开发环境中的服务器上看到这种情况。

在 JBOSS 日志中,记下日期和时间后面的+0100和值。+0000我假设这些是与 UTC 的偏移量。因此,如果您调整偏移量,上面的 JBOSS 日志将显示:

21/Jun/2017:07:46:12 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-40
21/Jun/2017:07:46:12 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-40
21/Jun/2017:07:47:58 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-41
21/Jun/2017:07:47:58 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-41
21/Jun/2017:07:47:58 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-41
21/Jun/2017:07:47:58 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-41
21/Jun/2017:07:52:22 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-53
21/Jun/2017:07:52:22 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-53
21/Jun/2017:07:52:22 +0000 "POST /resources/v1/messaging/ HTTP/1.1" 200 139 - default task-5

相关内容