screen 默认使用 -L 选项去开启日志,默认是 screenlog.0,如果再开启新的会话,那么日志就是screenlog.1,screenlog.2,screenlog.3...我们可以使用 -Logfile 去覆盖默认的规则,自定义自己的日志文件。
默认的screen会话是10秒间隔刷新一次日志,如果想修改这个间隔,可以通过 logfile flush命令去修改间隔时间。
开启串口,收集日志
screen -c /tmp/screen.conf -UdmSL testscreen /dev/ttyUSB0 115200
-dm starts the new screen session while remaining detached.
-S defines the session name.
-L enables logging to a file at 10 seconds intervals.
-U tell all scrren to use UTF-8 encoding
/tmp/screen.conf
配置文件
logfile /tmp/jira-log.log
logfile flush 1
logtstamp on
logtstamp after 5
log on
With logfile flush 1
we request that every 1 second the output be flushed to the log
The logtstamp on
option writes a timestamp to the log after a default 2 minutes of inactivity. We shorten that to 5 seconds with logtstamp after 5
.
log on
turns on the logging
时间格式定义
默认情况:-- 0:process-name -- time-stamp -- Jul/24/13 9:09:56 --
修改后: -- time-stamp -- 2013-07-24 09:59:35 --
logtstamp string "-- time-stamp -- %Y-%m-%d %0c:%s --\012"
这样,串口/dev/ttyUSB0 的日志就会被收集到 /tmp/jira-log.log
退出串口
screen -X quit