相关疑难解决方法(0)

为什么 `journalctl --list-boots` 与 `uptime` 和 `who -b` 报告的内容不匹配?

这是我使用的测试脚本:

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)

boot systemd reboot journalctl systemd-journald

5
推荐指数
1
解决办法
8577
查看次数

标签 统计

boot ×1

journalctl ×1

reboot ×1

systemd ×1

systemd-journald ×1