任何人都可以向我解释last
命令输出的最后一列的含义是什么?我对它对于reboot
伪用户的意义特别感兴趣。
reboot system boot 2.6.32-28-generi Sat Feb 12 08:31 - 18:09 (9+09:37)
Run Code Online (Sandbox Code Playgroud)
9+09:37 是什么意思?
当我调查以常规方式重新启动的服务器时,我开始查看“最后一个”实用程序,但问题是我无法找到这些列的确切含义。当然,我已经查看了那个人,但它不包含此信息。
root@webservice1:/etc# last reboot
reboot system boot 3.2.13-grsec-xxx Thu Apr 12 09:44 - 09:58 (00:13)
reboot system boot 3.2.13-grsec-xxx Thu Apr 12 09:34 - 09:43 (00:08)
reboot system boot 3.2.13-grsec-xxx Thu Apr 12 09:19 - 09:33 (00:13)
reboot system boot 3.2.13-grsec-xxx Thu Apr 12 08:51 - 09:17 (00:25)
reboot system boot 3.2.13-grsec-xxx Thu Apr 12 00:11 - 09:17 (09:05)
reboot system boot 3.2.13-grsec-xxx Wed Apr 11 19:40 - 09:17 (13:36)
reboot system boot 3.2.13-grsec-xxx Sun Apr 8 22:06 - 09:17 …
Run Code Online (Sandbox Code Playgroud) 将last -x reboot
最后两个条目显示为 的原因是still running
什么?此外,我很确定我没有在 16 年 12 月重新启动该服务器,尽管它可能与托管服务提供商有关。如果是这样,这会是预期的结果吗?
root@cthulhu-new ~ # last -x reboot
reboot system boot 4.13.0-0.bpo.1-a Sat Dec 16 06:26 still running
reboot system boot 4.13.0-0.bpo.1-a Thu Dec 7 07:56 still running
reboot system boot 4.13.0-0.bpo.1-a Wed Dec 6 11:10 - 07:55 (20:44)
wtmp begins Tue Dec 5 19:59:27 2017
Run Code Online (Sandbox Code Playgroud)
这是last -x shutdown
12 月 16 日没有条目的输出:
root@cthulhu-new ~ # last -x shutdown
shutdown system down 4.13.0-0.bpo.1-a Thu Dec 7 07:55 - …
Run Code Online (Sandbox Code Playgroud) 该系统有非常旧的靴子(2 年和 3 年),它们没有回收利用,我无法对其进行吸尘:
$ journalctl --list-boots --no-pager
-16 53baf678f0d749d6b390afea4a3ef96b Wed 2014-04-02 22:07:26 IDT—Wed 2014-04-02 22:46:08 IDT
-15 60a54132f5c8450d9b33a77819a037d1 Thu 2014-04-03 00:04:50 IDT—Thu 2014-04-03 12:30:21 IDT
-14 24b65a7e589d4479bf5020b98b8120b7 Wed 2015-04-01 03:10:01 IDT—Wed 2015-04-01 08:35:21 IDT
-13 43398d6d74c849bcb359a2d3963f4aaa Wed 2015-04-08 00:26:31 IDT—Wed 2015-04-08 00:26:31 IDT
-12 51b28f394cbb4699b2c4098297f73b2e Mon 2017-07-24 18:28:02 IDT—Mon 2017-07-24 19:08:37 IDT
-11 67467a640fb5413189f9cd518a56f668 Tue 2017-07-25 01:21:00 IDT—Mon 2017-07-24 22:54:40 IDT
-10 1370875e2f2c4b3c80c82901367b0835 Tue 2017-07-25 03:05:18 IDT—Tue 2017-07-25 01:18:51 IDT
-9 462c24a6b4cd487c834e121240bb880c Tue 2017-07-25 13:16:02 IDT—Tue 2017-07-25 18:50:32 IDT …
Run Code Online (Sandbox Code Playgroud) 这是我使用的测试脚本:
last_reboot=$(last reboot | grep 'still running' | awk '{for (i=5; i<=NF; i++) printf $i FS}' | awk '{for (i=1; i<=NF - 2; i++) printf $i FS}')
if [ "$last_reboot" ]; then
date -d "$last_reboot" '+last reboot: %Y-%m-%d'
fi
days=$(uptime | awk '{print $3}')
hours=$(uptime | awk '{print $5}' | sed -E 's/,$//')
h=$(echo "$hours" | cut -d: -f 1)
m=$(echo "$hours" | cut -d: -f 2)
date -d "- $days days - $h hours - $m minutes" '+uptime: %Y-%m-%d' …
Run Code Online (Sandbox Code Playgroud)