How do you use the "screen" command effectively?
Type in command
Check back on lost session
How do I carry out step 4?
migrated from stackoverflow.com Aug 17 '09 at 23:14
This question came from our site for professional and enthusiast programmers.
A simpler method that is useful for commands that leave logfiles or just throw some relevant output and do not need interactivity is nohup:
Screen is really powerful, and allows you to do exactly what you asked.
To see all your sessions, type
Once you've identified a screen session to reconnect too, try
which will nicely detach and re-attach your session.
You can also do a less nice,
which will detach and logout remotely, if nesscessary, then reattach, or if that session doesn't exist, it will create it and notify the user. You can add a "-t NAME" to give shells or programs a title.
Within screen, use
to create a new window (So you don't need 4000000 screen sessions to disconnect and reconnect from), and change between them with
Indexing from 0, of course:P
Since you seem a bit unfamiliar with screen, I'm going to assume you could use some other info. I like the following commands, like:
Which causes x to be the command character and y to be the character to generate a literal command character. The defaults are Ctrl-a and `a.
There's some more for you here: Screen! It's what's for programmers
A quick Google search found this screen guide
So from step b) you can detach the screen using :
"Ctrl - A" "d"
and then later after the connection has been lost and your connected once again find the screen using :
and then reattach using :
Here's what I have picked up about using screen (which I, too, have just started doing):
Also, when you start using screen, whenever you plan to leave, press
In addition, I can recommend taking a look at
The most important of these (to me) are:
you can also set up your environment to log you in and start screen right off the bat. There are many ways to do it. I chose to add this to my .bashrc file.
Step 4 is "screen -r"
If you got disconnected really forcefully, you might need to do "screen -r -d", to force it to disconnect from your old ssh session, which it thinks is still open.
If you want to see screen in Console then you have to write command
if you have to access the screen then you have to use below command