[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1025
  • Last Modified:

lost connection to linux server while running tar command

I'm stumbling my way through managing a linux server and have a question..

I have to connect via VPN and then use Putty to open a terminal to the server. I was running the tar command on a massive directory to create a backup, then the VPN connection was terminated and the putty connection went inactive. Which brings up three questions:
Did this interrupt the tar command?
If not, is there a way to verify it completed successfully or if it's still running?
And lastly, is there a better way to accomplish this task that isn't dependent on a persistent connection to the server?
  • 6
  • 5
1 Solution
Usually a break n the connection terminates all running commands in that shell unless screen is used or nohup precedes running of any commanding the background.
While the tar process may have been interrupted, the space used for the partial file wll not be freed.
I generally connect with remote systems using VNC.  This gives me an X display, just like running on a local system.  But I can disconnect (or have the connection fail) without the X session and remote login disappearing.   When I reconnect, the session is still live and I can check on status.   Take a look at http://tightvnc.com.
musickmannAuthor Commented:
Hmmm. I haven't considered using VNC. I inherited the servers from the previous person who was managing them, and so far nothing has seemed to be standard in their configuration.
It's a CentOS system, would that have a X display installed automatically, or will I have to install something else?
What Security Threats Are We Predicting for 2018?

Cryptocurrency, IoT botnets, MFA, and more! Hackers are already planning their next big attacks for 2018. Learn what you might face, and how to defend against it with our 2018 security predictions.

You can run rpm -qa | grep -i xorg
If you are comfortable with text/terminal access, install screen.
Screen provides the option to have multiple terminal windows from a single connection while preserving the session in the even of dropped connection

I.e after you connect. You will run screen

Then you can do screen new command which will create a new screen that you can use Carl-a screen_number.
When you loose connection you would use screen -D -RR to resume the running screen.
screen -list will display a list of screen session the user has had and you can use this information to resume the session from the list.
musickmannAuthor Commented:
Wow, I couldn't have asked for a more perfect answer, this is exactly what I Was looking for all this time! I feel like such a derp with always have been creating multiple Putty sessions. DOH!
musickmannAuthor Commented:
I've been using screen, and it's been very helpful. I just had a connection drop again in the middle of the session, but when I logged in again, the previous screen sessions weren't there.

I entered a screen session, began an FTP upload of a very large file
When the connection dropped, I reactivated the session (I use Putty), and went to list screen sessions and there were none, there should have been 2.

Did I misunderstand that screen would allow session recovery after connection drop?
No, screen is supposed to keep running on disconnect.  could you make sure did not reboot, uptime?
last | more
musickmannAuthor Commented:
Uptime is 5 days running.
I connect VPN to the network, then use Putty to connect to the server if that makes a difference.
musickmannAuthor Commented:
I just tried again to see if it would maintain. I started several screen sessions. Closed the Putty window, when I next login I type screen hit enter, then pull up a list of screens and only 1 is listed.
Is there a special method to reactivate existing screens upon re-logging in?
screen -list

screen -RDD <session_id> will resume that session.

Lets try to follow your steps. After you login to the server using putty you issue
screen (this is the main session, screen 0 though any remaining active screen means additional windows can be opened using the ctrl-c-ctrl a.)
you then want to access to server2 so you run
screen ssh user@server2 (this will not be opened as the next numerical screen, screen 1 crtl-a w will tell you how many sub sessions exist within this main screen  session. ctrl-a SHift-A will let you change the name of the individual screen sub session so it would be easier similar to using screen -t 'name of sub session')

If the systems to which you were connected reboot, the screen sub session to those will terminate as well.

To detach from your screen session, ctrl-c ctrl-d.
musickmannAuthor Commented:
screen list provides
There are screens on:
        31273.pts-4.localhost   (Detached)
        14431.pts-0.localhost   (Detached)
        28313.pts-4.localhost   (Detached)
        29573.test      (Detached)
        30347.pts-4.localhost   (Detached)
        28880.test      (Attached)
        30978.pts-0.localhost   (Detached)
7 Sockets in /var/run/screen/S-root.

Once I login through putty to this server, I only stay in this server, I dont ssh to any other servers.
When I attempt to reconnect to 30347.pts4 putty closes.

I'm going to reboot the server when I can to clear out the screens and then try it again, I wasn't using the screen -list command before, so that might be what I was missing. I will let you know.

I really appreciate the follow up!
screen -DRR <scketid from the list to resume that session>

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now