[SOLVED] how to start a screenlog from one command?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to start a screenlog from a shell script. The process is already running and I want to enable the screenlog just as my script starts then stop the screenlog at the end of my script.
I know I can screen into the task that is running and start the logging manually:
screen -r myTask
then
ctrl+a shift+h
then detach
ctrl+a ctrl+d
However I would like to get fancy!
I have tried all kinds of variations of the following without any luck.
screen -L -r myTask
screen -r myTask -X ^aa H ^aa ^ad
I see a lot of forums where people send commands into screen but I am not understanding the syntax for the command. I do not know what the ctrl+a would look like and what would the shift+h look like.
Process I am trying to start the screen log is started like this:
screen -h 1000 -d -m -S myTask
I can add a '-L' before the '-h' and it logs everything. However I would like to only log data during my script execution.
I feel like I am right there, but just not getting it. Any advise would be much appreciated.
I use screen to start a process that controls multiple other tasks. I get a lot of ouput from the screen and would like to only capture the data when I run a script that enduse problems to test my process for failures. If I can get the screenlog started and stoppped without attaching to the session I would have everything I need to find the bugs in my code.
I have been reading the man & help pages as well as experiment with different options. I feel like I am fishing in the dark though.
Not sure what you mean by 'started the screenlog manually'. It may be that you refer to the matter of launching screen in detached mode. When commanding a screen session that has been launched in detached mode, and has not ever been attached, you need to use the '-p 0' option:
Code:
screen -S MYSCREEN/ -p 0 -X logfile '/some/filespec'
screen -S MYSCREEN/ -p 0 -X log on
#
# ... some time later...
#
screen -S MYSCREEN/ -X log off
Not sure what you mean by 'started the screenlog manually'. It may be that you refer to the matter of launching screen in detached mode. When commanding a screen session that has been launched in detached mode, and has not ever been attached, you need to use the '-p 0' option:
Code:
screen -S MYSCREEN/ -p 0 -X logfile '/some/filespec'
screen -S MYSCREEN/ -p 0 -X log on
#
# ... some time later...
#
screen -S MYSCREEN/ -X log off
--- rod.
That is exactly what I needed! Thanks Rod, You saved me from a lot of pain.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.