在 Linux 上应如何解释最后输出中的时间戳?
$ 最后 -aid foouser pts/12 2月15日星期日 07:30 - 15:23 (2+07:52) XXX.YYY.ZZZ.QQQ
Sun Feb 15 07:30 - 15:23 部分非常明显。 该用户于周日 7:30 登录。 但(2+07:52)还不清楚。 7:52 是两个时间之差,那么 2+ 部分是多少呢?
$ last -aid foouser pts/12 Sun Feb 15 07:30 - 15:23 (2+07:52) XXX.YYY.ZZZ.QQQ
The Sun Feb 15 07:30 - 15:23 part is pretty obvious. The user logged in at 7:30 on Sunday. But (2+07:52) is unclear. 7:52 is the difference between the two times, but what's the 2+ part?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用源代码,Luke:
这是来自 Debian 上的
sysvinit
源代码包。给那些不懂 C 语言的人的提示:这是天数。
Use the source, Luke:
This is from the
sysvinit
source package on Debian.Hint for those without knowledge in C: it's the number of days.
括号之间的字符串是会话的持续时间。 正如您所注意到的,时间是结束时间和开始时间之间的差。 2+ 是天数 跳注意到。
在某些时候,这个问题可能应该转移到服务器故障,因为它最有可能引起系统管理员的兴趣。
一旦您知道自己在看什么,它就是一种相当可读的格式。 如果我设计输出,我想我会将星期几设为可选,并将整个结束日期放入字符串中。 更好的是让日期戳是可配置的。 这样,输出就可以更容易地被另一个程序使用。
如果用户已注销会话,则可以使用正则表达式轻松选出实际持续时间:
The string between the parentheses is the duration of the session. As you note, the time is the difference between the end and start times. The 2+ is the number of days as hop noted.
At some point, this question probably should be moved over to Server Fault since it's most likely to be of interest to System Administrators.
It's a fairly readable format once you know what you are looking at. If I were designing the output, I think I'd make the day of the week optional and put the entire end date in the string instead. Even better would be to let the date stamp be configurable. That way, the output could be more easily used by another program.
The actual duration, if the user has logged out of the session is fairly easy to pick out with a regular expression:
那可能是几天,但我不确定; 这也不是一个编程问题。
Those might be days but I'm not sure; also this is not a programming question.