LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 03-08-2013, 08:51 PM   #1
coolCAT
LQ Newbie
 
Registered: Mar 2013
Location: Central IL
Distribution: Ubuntu 12.04
Posts: 5

Rep: Reputation: Disabled
Cool how to start a screenlog from one command?


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.
 
Old 03-08-2013, 09:51 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
What's your ultimate purpose? Screen (see manual here) command is somewhat like nohup.
As much as I know, it's useful when you work remotely.
 
Old 03-09-2013, 05:10 PM   #3
coolCAT
LQ Newbie
 
Registered: Mar 2013
Location: Central IL
Distribution: Ubuntu 12.04
Posts: 5

Original Poster
Rep: Reputation: Disabled
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.
 
Old 03-09-2013, 06:21 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I think you can specify the logfile name, start and stop the logging process by using the '-X' option plus an argument:
Code:
#
#  Start the screen session 
#
screen -S MYSCREEN
Then, from a different shell...
Code:
screen -S MYSCREEN/ -X logfile '/some/filespec'
screen -S MYSCREEN/ -X log on
#
# ... some time later...
#
screen -S MYSCREEN/ -X log off
--- rod.

Last edited by theNbomr; 03-10-2013 at 01:00 PM.
 
1 members found this post helpful.
Old 03-10-2013, 10:14 AM   #5
coolCAT
LQ Newbie
 
Registered: Mar 2013
Location: Central IL
Distribution: Ubuntu 12.04
Posts: 5

Original Poster
Rep: Reputation: Disabled
@theNbomr,

Thanks! That is exactly what I was trying to do! You are awesome!
 
Old 03-18-2013, 02:53 PM   #6
coolCAT
LQ Newbie
 
Registered: Mar 2013
Location: Central IL
Distribution: Ubuntu 12.04
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by theNbomr View Post
I think you can specify the logfile name, start and stop the logging process by using the '-X' option plus an argument:
Code:
#
#  Start the screen session 
#
screen -S MYSCREEN
Then, from a different shell...
Code:
screen -S MYSCREEN/ -X logfile '/some/filespec'
screen -S MYSCREEN/ -X log on
#
# ... some time later...
#
screen -S MYSCREEN/ -X log off
--- rod.
Rod,

I have found this actually only works if I have started a screenlog manually. If I have not started the screenlog manually then it is not working.

-- Josh
 
Old 03-18-2013, 03:56 PM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
1 members found this post helpful.
Old 03-21-2013, 10:17 AM   #8
coolCAT
LQ Newbie
 
Registered: Mar 2013
Location: Central IL
Distribution: Ubuntu 12.04
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by theNbomr View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] What is the command to start GDM? MisterHerbal98 Linux - Newbie 5 09-19-2011 09:45 AM
How to start squid command when computer start fedora rajunetha LinuxQuestions.org Member Intro 6 10-01-2009 12:48 AM
why my ntop can't start using service ntop start command cmx08 Linux - Software 5 10-21-2008 10:52 PM
Why after start of a command the invitation for input next command has not appeared. ukrainet Linux - General 3 06-24-2005 08:16 AM
Start Command David@330 Linux - Newbie 5 10-19-2004 11:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration