Solved

lost connection to linux server while running tar command

Posted on 2012-04-07
12
981 Views
Last Modified: 2012-08-13
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?
0
Comment
Question by:musickmann
  • 6
  • 5
12 Comments
 
LVL 76

Expert Comment

by:arnold
ID: 37820379
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.
0
 
LVL 8

Expert Comment

by:eager
ID: 37821382
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.
0
 
LVL 2

Author Comment

by:musickmann
ID: 37821945
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?
0
 
LVL 76

Accepted Solution

by:
arnold earned 500 total points
ID: 37821967
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.
http://www.manpagez.com/man/1/screen/
0
 
LVL 2

Author Closing Comment

by:musickmann
ID: 37842325
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!
Thanks!
0
 
LVL 2

Author Comment

by:musickmann
ID: 37860746
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?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 76

Expert Comment

by:arnold
ID: 37861096
No, screen is supposed to keep running on disconnect.  could you make sure did not reboot, uptime?
last | more
0
 
LVL 2

Author Comment

by:musickmann
ID: 37861136
Uptime is 5 days running.
I connect VPN to the network, then use Putty to connect to the server if that makes a difference.
0
 
LVL 2

Author Comment

by:musickmann
ID: 37861220
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?
0
 
LVL 76

Expert Comment

by:arnold
ID: 37861423
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.
q
0
 
LVL 2

Author Comment

by:musickmann
ID: 37862247
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!
0
 
LVL 76

Expert Comment

by:arnold
ID: 37863490
screen -DRR <scketid from the list to resume that session>
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now