2

I'm trying to parse the output of a screen session from a script. The man page of screen says I can use the command logfile, but gives no indication of the syntax to use when I launch screen non-interactively.

I would like to do something like this:

screen -L -d -m executable.app 

But instead of having the output written to screenlog.0, have it written to a file of my choice.

2 Answers 2

3

The only way I can think of to have a custom log filename is to create a temporary .screenrc, add logfile <LOG-NAME> to it and tell screen to use it. Like this:

cp ~/.screenrc /tmp/
echo "logfile CUSTOM_NAME" >> /tmp/.screenrc
screen -c /tmp/.screenrc -L -d -m <PROGRAM>
1
  • 1
    If this answer works for you mark it as accepted. If it doesn't provide more details so that we can work on a better solution. Jun 11, 2014 at 23:33
2

I have used the following to start screen session with a specific logfile.

screen -dmS <sock_name> && \
screen -S <sock_name> -X logfile <logfile_name> && \
screen -S <sock_name> -X log

Description:

screen -dmS <sock_name>                         #Start detached screen session
screen -S <sock_name> -X logfile <logfile_name> #Use logfile command to set logging file
screen -S <sock_name> -X log                    #Use log command to start logging

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .