Linux 是否可以从 -L 标志命名“屏幕”日志文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15026184/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 19:06:29  来源:igfitidea点击:

Is it possible to name the 'screen' logfile from the -L flag?

linuxlogginggnu-screen

提问by Justin

Upon running Screenwith the -L flag, a file called 'screenlog.0' is created and all output written to it (which is great), but I will be running several Screen sessions and I need to identify the logs with a unique number. Is it possible to change the log file name?

使用 -L 标志运行Screen 后,会创建一个名为“screenlog.0”的文件并将所有输出写入其中(这很棒),但我将运行多个 Screen 会话,我需要使用唯一编号标识日志. 是否可以更改日志文件名?

采纳答案by Eun

You can edit your .screenrcfile and add something like this:

您可以编辑.screenrc文件并添加如下内容:

logfile /tmp/myownlog

日志文件 /tmp/myownlog

It is also answered at Specifying a log name for screen output without relying on .screenrc.

它也在指定屏幕输出的日志名称而不依赖于 .screenrc 中得到回答。

回答by Juan Enciso

Alternatively, there's a way to do it online.

或者,有一种方法可以在线完成。

Enter command mode in Screen via Ctrl+a, :and use the logfilecommand with the name of the file you want as argument, for example:

通过Ctrl+在 Screen 中进入命令模式a:并使用logfile命令和您想要的文件名作为参数,例如:

logfile whatevernameyoulike.log

Source: Screen man page

来源:屏幕手册页

回答by Nan Wang

Probably the easiest way is to use the following:

可能最简单的方法是使用以下方法:

screen -L -Logfile log_filename your_command