logging - GNU screen 上的 screen 日志和硬拷贝之间的差异

标签 logging terminal gnu-screen

简介

我是新使用GNU screen,我使用它主要是因为我不想在我的 SSH 连接意外关闭时丢失我的工作,也因为我想保留一个我的终端上打印的每个输出的日志文件(至少是一些最近的轨道)

对于 SSH 的东西,我想 Ctrl+a d 来分离和 screen -rscreen -r session_name 重新附加到某个 session 解决了我所有的问题,现在我正在尝试了解日志记录。

我在this link上找到了screenloghardcopy ,基本上是说:

hardcopy Ctrl+a h Writes out the current display contents to the file hardcopy.n in the window's default directory, where n is the number of the current window. This either appends or overwrites the file if it exists, as determined by the hardcopy_append command.

log Ctrl+a H Begins/ends logging of the current window to the file screenlog.n in the window's default directory, where n is the number of the current window. If no parameter is given, the logging state is toggled. The session log is appended to the previous contents of the file if it already exists. The current contents and the contents of the scrollback history are not included in the session log. Default is off.

<小时/>

观察到的行为

因此,据我了解并尝试使用它们,在启用 screenlog 后,它会不断记录我编写的所有内容以及该文件中终端的所有输出(恰好是 $HOME 对我来说)包括那些改变颜色的字符,如 \033[1;31mm。如果我执行cat screenlog.0,它有时会无限期地打印文件而崩溃,但是好的,我可以使用编辑器或在另一个 session 中打开它......

至于硬拷贝,显然它不会跟踪命令,也不会跟踪输出的颜色,而且我不知道它是否只需要终端中可见的几行或发生的所有事情在那次 session 上,有人可以向我澄清这一点吗?

最后,我在 Terminator 上打开 screen 而不是传统终端,即使我在不​​同的窗口上打开不同的 screen session Terminator 的所有日志都会转到 screenlog.0hardcopy.0。对于 screenlog,它是否会与其他 session 上输出的另一个进程冲突或覆盖它?如何创建不同的 screenlog.n 文件并将它们放在 $HOME 以外的目录中?

<小时/>

进一步考虑

总结一下,推荐哪一个? 对于这个巨大的问题,我感到抱歉,但我正在尝试以一种有助于澄清我在其他地方很难找到的这些日志的详细信息的方式来编写它。如果我说错了请随时纠正我:)

最佳答案

hardcopy 命令不保存字符属性(颜色、粗体等),但使用“-h”参数还保存回滚缓冲区的内容。

硬拷贝文件的目标目录可以通过hardcopydir命令设置;现有文件不会移动,并且此设置适用于当前打开的所有窗口和将来的窗口;日志文件的目录是“窗口的默认目录”——这可以使用 chdir 命令更改;它适用于当前窗口和所有 future 窗口。

日志文件名称模式可以通过logfile命令设置。所有screen的转义序列都应该在该模式下工作;例如,日志文件 screenlog.%Y%m%d.%S.%n。但是,硬拷贝文件名模式是硬编码的。

关于logging - GNU screen 上的 screen 日志和硬拷贝之间的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18127728/

相关文章:

linux - 如何从独立的 GNU screen session 中邮寄命令的输出?

javascript - 从调用当前函数的位置查找行号

python - 如何捕获一系列 Celery 任务执行过程中产生的所有 python 日志记录?

ruby-on-rails - 启动 Rails 服务器时出错 : warning: Insecure world writable dir/usr in PATH, 模式 040777

bash - 如何在没有进一步用户交互的情况下使用 sudo 在单独的终端中运行命令

bash - 无法通过 ssh 执行 screen : Must be connected to a terminal

json - ELK Stack - 进一步反序列化 Kubernetes 中归档的 "message"

elasticsearch - 麋鹿。找不到嵌套值

android - Bash:查找并替换脚本中的文本

php - 通过 php 用户在 root 上管理 Linux screen