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, wheren
is the number of the current window. This either appends or overwrites the file if it exists, as determined by thehardcopy_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 isoff
.
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 :)
screen
, take a look atmux
too. – William Purselltmux
and I don't have root permissions, so I'm stuck withscreen
. By the way, `tmux is simpler/better/safer or something like that? – rafatmux
handles the copy buffer. You can change panes/windows/sessions while keeping different views in different states in the scroll back, which is not possible with screen (or wasn't the last time I looked). – William Pursell