大网数据广告活动
服务器运维问答

Start/Stop times of Linux PC

· 52CE 我爱测

I would like to see the start/stop times of a Linux PC. I found this command, but the output is wrong: last reboot -F reboot system boot 4.15.0-46-generi Thu Mar 14 10:04:27 2019 - Thu Mar 14 15:31:11 2019 (05:26) That's not true…

问题原文

原帖链接 · guettli · CC BY-SA 4.0

I would like to see the start/stop times of a Linux PC.

I found this command, but the output is wrong:

last reboot -F
reboot   system boot  4.15.0-46-generi Thu Mar 14 10:04:27 2019 - Thu Mar 14 15:31:11 2019  (05:26)

That's not true. Instead of 10:04 it is 09:04.

See related question: https://askubuntu.com/questions/854567/last-reboot-is-missing-one-hour/859782

How can I see the correct start/stop times on Ubuntu 18.04?

已采纳解答

原帖链接 · Chaoxiang N · CC BY-SA 4.0

# timestamps corresponds to your current timezone
user@node:~$ journalctl --list-boots
-3 0f2fcb9569384a2aa2d5492505f86cda Tue 2018-11-27 16:45:22 CET—Thu 2018-11-29 10:10:07 CET
-2 646787bd244d4230a5986f00207c1e8c Sun 2019-02-24 19:50:23 CET—Tue 2019-02-26 22:49:29 CET
-1 c922041a9a3847babd51ac79dd06923c Wed 2019-02-27 08:27:28 CET—Sun 2019-03-03 08:52:52 CET
 0 0aa03fbca4bf4976b922f9f77c63f65a Sun 2019-03-03 09:02:47 CET—Mon 2019-03-18 17:10:08 CET

# timestamps corresponds to universal timezone
user@node:~$ journalctl --list-boots --utc
-3 0f2fcb9569384a2aa2d5492505f86cda Tue 2018-11-27 15:45:22 UTC—Thu 2018-11-29 09:10:07 UTC
-2 646787bd244d4230a5986f00207c1e8c Sun 2019-02-24 18:50:23 UTC—Tue 2019-02-26 21:49:29 UTC
-1 c922041a9a3847babd51ac79dd06923c Wed 2019-02-27 07:27:28 UTC—Sun 2019-03-03 07:52:52 UTC
 0 0aa03fbca4bf4976b922f9f77c63f65a Sun 2019-03-03 08:02:47 UTC—Mon 2019-03-18 16:10:08 UTC

UTC timezone is universal that's why it is useful to avoid any daylight saving time misunderstanding issues.

From journalctl man page :

       --list-boots
           Show a tabular list of boot numbers (relative to the current boot), their IDs, and the timestamps of the first and last message pertaining to the boot.

PS : in case you have only one line returned by journalctl, just create folder /var/log/journal to enable multiple on-disk journal retention

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-03-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。