gpt4 book ai didi

linux - 我怎样才能跟踪 dmesg

转载 作者:行者123 更新时间:2023-12-02 01:44:23 26 4
gpt4 key购买 nike

我使用的是 Ubuntu 20.04.3 LTS。我正在尝试监控与我的 Arduino 连接的串行端口。我看到我的 friend 使用以下命令(他在我的笔记本电脑上执行):

tail -f {dmesg,syslog} | grep -i tty

每当我插入和拔出 arduino 时,终端总是保持显示串行端口名称及其状态。但是当我自己尝试时,它说没有这样的文件或目录。我搜索并尝试了以下命令:

tail -f var/log/dmesg
tail -f var/log/{dmesg,syslog}

但是好像没有显示串口或者跟不上状态。你能帮我出出主意吗?

最佳答案

你可以使用

dmesg -W | grep -i tty

-w, --follow

Wait for new messages. This feature is supported only on systems with a readable /dev/kmsg (since kernel 3.5.0).

所以输出会是这样的

rexter@rexter:/media/rexter/REXDRIVE$ dmesg -w | grep -i tty
[ 0.112876] printk: console [tty0] enabled
[ 332.500320] Bluetooth: RFCOMM TTY layer initialized

如果你只想获取新消息并想隐藏旧消息,那么使用-W

-W, --follow-new

Wait and print only new messages.

奖励:使用-T获取时间戳,这样就可以得到接收日志的时间。

谢谢你:)

关于linux - 我怎样才能跟踪 dmesg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71107453/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com