I have a job launched in a screen session which is expected to run for several hours. From time to time I'm requested to check if job is still running and guess at wich % of work is.

Guess if it is working or not is as simple as perform a ps -fu $LOGNAMEto check if the process is still alive, but in order to guess the % I need to check the output of the program (it outputs some information which can be used with grep -n to see which line of file it is currently processing).

I can attach the session (screen -R jobLoadItems) and take a look to it, but I would like to do it without attaching to session again. I already checked to perform inside the screen session Ctrla-H to activate screenlog but it's so verbooooooooose it will take all disk space available.

So there is a way to just print last lines of the screen session without attaching to it? (something like screen -S jobLoadItem -Q display last 50 lines)


You can use

 screen  -r <name of sesion> -X hardcopy

this is same as Ctrla-h

from the man page:

Ctrla-h (hardcopy)
Write a hardcopy of the current window to the file "hardcopy.n".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.