Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between Screenlog and Hardcopy on GNU Screen

Introduction

I'm new using GNU screen, and I'm using it mostly because I don't want to lose my work if unexpectedly my SSH connection closes, and also because I want to keep a logfile of every output printed on my terminal (at least some recent tracks)

For SSH stuff, I guess Ctrl+a d to detach and screen -r or screen -r session_name to re-attach to some session solve all my problems, now I'm trying to understand logging.

I found screenlog and hardcopy on this link, which basically says:

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.


Observed Behavior

So, as far as I understood by this and trying to use them, after enabling screenlog, it keeps logging everything I write and all the outputs of terminal in that file (which happens to go $HOME for me) including those characters to change color like \033[1;31mm. If I do cat screenlog.0, it crashes sometimes printing the file indefinitely, but ok, I can open it with an editor or in another session...

As for hardcopy, apparently it doesn't keep tracking commands, nor colors of outputs, and I don't know if it takes only those few lines that are visible in terminal or everything that happened on that session, could someone clarify this to me?

Finally, I'm opening screen on Terminator instead of the classical terminal, and even if I open different screen sessions on different windows of Terminator, all logs go to screenlog.0 or hardcopy.0. In the case of screenlog, will it conflict with another process that's being output on other sessions or overwrite it? How can I create different screenlog.n files and put them in a directory other than $HOME?


Further Considerations

Just to conclude, which one is recommended? Sorry for this huge question, but I'm trying to write it in a way that it can be useful to clarify details of these logs that I'm having a hard time to find in other places. Feel free to correct me if I said something wrong :)

like image 285
rafa Avatar asked Aug 08 '13 13:08

rafa


People also ask

How does GNU screen work?

GNU Screen is a terminal multiplexer, a software application that can be used to multiplex several virtual consoles, allowing a user to access multiple separate login sessions inside a single terminal window, or detach and reattach sessions from a terminal.


1 Answers

hardcopy command does not save character attributes (colors, bold etc.) but, with '-h' argument also saves contents of scrollback buffer.

Destination directory for hardcopy files can be set via hardcopydir command; existing files are not moved, and this setting applies to all windows currently open and future ones; directory for log files is "window's default directory" -- this can be changed with chdir command; it applies to current window and all future ones.

Log file name pattern can be set via logfile command. All screen's escape sequences should work in the pattern; for example, logfile screenlog.%Y%m%d.%S.%n. However, hardcopy file name pattern is hardcoded.

like image 184
sendmoreinfo Avatar answered Nov 08 '22 07:11

sendmoreinfo