Linux Screen: Recording Screen logs
Screen is the Linux window manager. You can create multiple screen sessions, and each screen session can create multiple window windows. Each window is like an actual ssh terminal.
Screen details:
Linux Screen ultra-Concise tutorial
Common Screen commands in Linux
Zabbix sends Screen graphical reports by email
Linux virtual terminal command Screen usage
Linux tips: use Screen to manage your remote sessions
The following describes how to record screen logs.
Method 1:
When starting, add the option-L (Turn on output logging.) to generate the screenlog.0 file in the current directory.
Screen-L-dmS test indicates to start a session in disconnected mode. The session name is test.
Screen-r test connects to the session. All screen outputs in the session are recorded in the screenlog.0 file.
Method 2:
If option-L is not added, press ctrl + a H under screen session to generate the screenlog.0 file in the current directory.
Press ctrl + a H for the first time, and the Creating logfile "screenlog.0" will be displayed in the lower left corner of the screen to start logging.
Press ctrl + a H again, And Logfile "screenlog.0" closed will be displayed in the lower left corner of the screen. Stop logging.
The preceding two methods have one disadvantage: when multiple screen sessions are created, each session logs to the screenlog.0 file. Contents in screenlog.0 are messy.
The solution is as follows, so that each screen session window has a separate log file.
Add the following line at the end of the screen configuration file/etc/screenrc:
Logfile/tmp/screenlog _ % t. log
% T indicates the name of the window, which corresponds to the-t parameter of screen. Therefore, when we start screen, we need to specify the window name, for example:
Screen-L-t window1-dmS test indicates to start the test session. The window name of the test session is window1. Screen logs are recorded in/tmp/screenlog_window1.log. If the-L parameter is not added at startup, press ctrl + a H under screen session, and the log will be recorded in/tmp/screenlog_window1.log.
This article permanently updates the link address: