Linux dmesg显示可读时间方式

直接用dmesg显示系统信息,很难看

[95721.670025] snapshot device recevied [read] io request, access on dev sector[272], length is [240] sectors.
[95721.670363] device is closed
[95721.693207] device is closed
显示的时间没有办法看。

使用dmesg --help看到,如下:

Usage:
 dmesg [options]

Display or control the kernel ring buffer.

Options:
 -C, --clear                 clear the kernel ring buffer
 -c, --read-clear            read and clear all messages
 -D, --console-off           disable printing messages to console
 -E, --console-on            enable printing messages to console
 -F, --file           use the file instead of the kernel log buffer
 -f, --facility       restrict output to defined facilities
 -H, --human                 human readable output
 -k, --kernel                display kernel messages
 -L, --color[=]        colorize messages (auto, always or never)
                               colors are enabled by default
 -l, --level          restrict output to defined levels
 -n, --console-level set level of messages printed to console
 -P, --nopager               do not pipe output into a pager
 -r, --raw                   print the raw message buffer
 -S, --syslog                force to use syslog(2) rather than /dev/kmsg
 -s, --buffer-size    buffer size to query the kernel ring buffer
 -u, --userspace             display userspace messages
 -w, --follow                wait for new messages
 -x, --decode                decode facility and level to readable string
 -d, --show-delta            show time delta between printed messages
 -e, --reltime               show local time and time delta in readable format
 -T, --ctime                 show human readable timestamp (may be inaccurate!)
 -t, --notime                don't print messages timestamp
     --time-format  show time stamp using format:
                               [delta|reltime|ctime|notime|iso]
Suspending/resume will make ctime and iso timestamps inaccurate.

 -h, --help     display this help and exit
 

可以使用-T来显示可读时间,如下:

dmesg -T

[Fri Aug 31 17:55:32 2018] device is closed
[Fri Aug 31 17:55:32 2018] device is closed
 

你可能感兴趣的:(driver开发,Linux,C++)