`last` 命令输出的第 10 列的目的是什么?

boa*_*der 3 last

last在 RHEL的命令输出中看到一个可疑的模式:

$ last reboot
reboot   system boot  3.10.0-514.21.1. Wed Dec 13 10:25 - 11:53  (01:28)    
reboot   system boot  3.10.0-514.21.1. Mon Oct 30 16:23 - 11:53 (43+20:30)  
reboot   system boot  3.10.0-514.21.1. Fri Oct 20 16:53 - 11:53 (53+20:00)  
reboot   system boot  3.10.0-514.21.1. Mon Oct 16 09:21 - 11:53 (58+03:32)  
reboot   system boot  3.10.0-514.21.1. Fri Aug 25 15:53 - 11:53 (109+21:00) 
reboot   system boot  3.10.0-514.21.1. Tue Aug 22 15:36 - 11:53 (112+21:16) 
reboot   system boot  3.10.0-514.21.1. Fri Jul 21 16:38 - 11:53 (144+20:15) 
reboot   system boot  3.10.0-514.21.1. Fri Jun  9 15:00 - 16:18 (42+01:17)  
reboot   system boot  3.10.0-514.21.1. Mon Jun  5 11:20 - 16:18 (46+04:57)  
reboot   system boot  3.10.0-514.21.1. Thu Jun  1 09:49 - 16:18 (50+06:28)  
reboot   system boot  3.10.0-514.el7.x Wed May 31 17:46 - 09:49  (16:02)   
Run Code Online (Sandbox Code Playgroud)

即,第 10 列在几行上显示相同的时间基准(例如,11 : 53七次,16:18三次)。

man页面没有解释每列应该代表什么。

您知道last命令输出的第 10 列的用途吗?

Ste*_*itt 5

列出重新启动时,第十列显示引导后的最后一次“停机时间”,系统关闭的时间,只要last可以确定。这实际上涉及从存储在系统中的信息中组合多个记录;这样做,last跟踪它看到的最后一次停机时间,并在显示“重新启动”行时盲目地使用它。

因此,如果系统突然关闭,则不会存储关闭时间,last而是使用之前的记录。查看您的结果:

reboot   system boot  3.10.0-514.21.1. Wed Dec 13 10:25 - 11:53  (01:28)    
reboot   system boot  3.10.0-514.21.1. Mon Oct 30 16:23 - 11:53 (43+20:30)  
reboot   system boot  3.10.0-514.21.1. Fri Oct 20 16:53 - 11:53 (53+20:00)  
reboot   system boot  3.10.0-514.21.1. Mon Oct 16 09:21 - 11:53 (58+03:32)  
reboot   system boot  3.10.0-514.21.1. Fri Aug 25 15:53 - 11:53 (109+21:00) 
reboot   system boot  3.10.0-514.21.1. Tue Aug 22 15:36 - 11:53 (112+21:16) 
reboot   system boot  3.10.0-514.21.1. Fri Jul 21 16:38 - 11:53 (144+20:15) 
reboot   system boot  3.10.0-514.21.1. Fri Jun  9 15:00 - 16:18 (42+01:17)  
reboot   system boot  3.10.0-514.21.1. Mon Jun  5 11:20 - 16:18 (46+04:57)  
reboot   system boot  3.10.0-514.21.1. Thu Jun  1 09:49 - 16:18 (50+06:28)  
reboot   system boot  3.10.0-514.el7.x Wed May 31 17:46 - 09:49  (16:02)
Run Code Online (Sandbox Code Playgroud)

last发现12月13日11点53分有关机记录,然后有几条记录开始时间;所以它使用了所有这些的单一关闭时间。然后它在 6 月 9 日 16 点 18 分找到了 42 天的关闭记录,并再次使用了该记录,因为直到 6 月 1 日 09 点 49 分才找到任何其他关闭记录。

您可以在last源代码中看到这一点;搜索“ lastdown”以查找更新(和使用)的位置。