Home > Linux Command Line > SCREEN command use cases

SCREEN command use cases

 
 
Sometimes we have to control job creation & termination via screen from inside a bash or shell script. Pasted below are some onliner’s which you will find useful.
 
1) Create screen test
 

reynold@jackal:~/$ screen -dmS test /usr/bin/top 
reynold@jackal:~/$ screen -ls
There is a screen on:
	10222.test	(07/01/2014 02:52:58 AM)	(Detached)
1 Socket in /var/run/screen/S-reynold.

reynold@jackal:~/$ 

 
2) Terminate the screen
 

reynold@jackal:~/$ screen -S test -X "quit"
reynold@jackal:~/$ screen -ls
No Sockets found in /var/run/screen/S-reynold.

reynold@jackal:~/$ 

 

3) Start a screen job which have command output piped. The first screen creation command won’t work in this case.
 

root@jmail7:~# screen -dmS straycustomerdirs bash -c 'cat /root/ops/reynold/straycustomerdirs.list | xargs rm -vrf $1'
root@jmail7:~#

 

4) To list all running screens,
 

screen -ls

 
5) To connect to an already running screen,
 

screen -rx SCREENNAME

 
6) To create a another screen inside a screen (yeah, its just sounds like dream inside a dream as in movie Inception 😀 ),
 

Ctrl + a + c

 
7) To list all subscreens inside a screen,
 

Ctrl + a + "

 

Advertisements
Categories: Linux Command Line
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: