admin管理员组文章数量:1125549
We want to capture all output of console on an embedded board which running Linux.
cat /proc/cmdline | grep -oE 'console=\S+'
shown console=ttyS2,115200n8
We would use a PC to login a testing board by tty terminal, such as minicom -D /dev/ttyUSB2
, and then run a record command, and then disconnect tty, and then goto another board. Once test finished, we can check each recorded file which saved in each board.
I tested running cat /dev/ttyS2 | tee ttyS2.log
or cat /dev/console | tee console.log
in ssh session, they cannot capture messages outputted to console.
I also tested script
command. It cannot capture following output too if run it in background.
#include <iostream>
#include <thread>
using namespace std;
// clang++ -std=c++23 -stdlib=libc++ bgrun.cpp
int main(int argc, char *argv[])
{
int timeout = argc > 1 ? stoi(argv[1]) : 1;
while (true)
{
system("echo; date");
cout << "cout: Waiting for " << timeout << " second(s)" << endl;
cerr << "cerr: Waiting for " << timeout << " second(s)" << endl;
this_thread::sleep_for(chrono::seconds(timeout));
}
return 0;
}
本文标签:
版权声明:本文标题:How to record all output of Linux console? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736663151a1946520.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论