Leaving jobs running on remote server

Sometimes I need to run a job on a remote server (linux) that takes pretty long time. And if I have to close the connection, the job will be terminated. To overcome this problem, in the remote server, type:

$ screen

This will attach a new screen, and start with a command line as normal. You can run the job now, and to leave this screen, we type “Ctrl-A” and then “D”. This is to “D”etach the screen. You will return to the previous prompt. To see the available screen, type:

$ screen -ls

There is a screen on:
6288.pts-2.floss        (Detached)
1 Socket in /var/run/screen/S-kurniawano.

Now to re-attach type:

$ screen -r 6288

where 6288 is the ID no obtained from the screen -ls command.

Advertisements

2 Responses

  1. 1. If you have just one screen detached you can type screen -r without the number.

    2. If you have an attached screen and you want to connect to it you can type screen -d -r and it will detach whoever is there and reattach you.

    Tal

  2. I think the nohup utility is better for this. (See: http://wiki.christophchamp.com/index.php/Nohup)

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: