LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-09-2016, 10:43 PM   #1
slac-in-the-box
Member
 
Registered: Mar 2010
Location: oregon
Distribution: slackware64-14.2
Posts: 208

Rep: Reputation: 79
make over remote ssh connection


Hello LQ

I am connected to a remote server via ssh, and am compiling software with the traditional configure, make, and make install method. My internet is 4g hotspot created by my phone, and during the make, I lost connection when train went through tunnel.

Will make still continue on the remote server? If I reconnect is there a way to view the old process? Or, if I wait long enough, can I assume it finished, reconnect, and proceed with make install?
 
Old 05-10-2016, 01:09 AM   #2
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,845
Blog Entries: 36

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
No, it won't continue unless you used something like nohup.

You should use a terminal multiplexer such as screen or tmux. My personal preference is screen.

https://nathan.chantrell.net/linux/a...ion-to-screen/

See section detaching and reattaching sessions.

Last edited by sag47; 05-10-2016 at 01:12 AM.
 
2 members found this post helpful.
Old 05-10-2016, 02:05 AM   #3
ondoho
Senior Member
 
Registered: Dec 2013
Posts: 4,606

Rep: Reputation: 977Reputation: 977Reputation: 977Reputation: 977Reputation: 977Reputation: 977Reputation: 977Reputation: 977
Quote:
Originally Posted by slac-in-the-box View Post
My internet is 4g hotspot
i've been reading many times of the advantages of mosh which seems to address these problems.
always wanted to try it myself...
 
1 members found this post helpful.
Old 05-10-2016, 03:21 AM   #4
slac-in-the-box
Member
 
Registered: Mar 2010
Location: oregon
Distribution: slackware64-14.2
Posts: 208

Original Poster
Rep: Reputation: 79
Thanks for answering. I was compiling a kernel, and the bzImage appeared, so I thought maybe it had completed. But I don't want to go through a lot of hoops and have it panic in the end; which is why I asked.

Thanks for both suggestions! Both seem like promising solutions. I'm going to try them in order, if running make in background as daemon doesn't do it. While waiting for a response, I tried this:
Code:
root@myhost# make bzImage > makeout &
[1] 13385
A file called makeout appeared, and I tailed a few lines, and later again, and the lines changed so I know the file is filling up with the output. Hopefully, if my connection drops, the process 13385 will continue. I'll reconnect in the morning once I wake up, and tail the end of makeout to see if it looks like it completed. If not I will try screen and mosh, which look like things to try anyways.

Thanks for answering.
 
Old 05-10-2016, 03:47 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,483

Rep: Reputation: 2425Reputation: 2425Reputation: 2425Reputation: 2425Reputation: 2425Reputation: 2425Reputation: 2425Reputation: 2425Reputation: 2425Reputation: 2425Reputation: 2425
you need to use:
Code:
nohup make bzImage > makeout &
otherwise the lost connection will(may) kill that make.
 
1 members found this post helpful.
Old 05-10-2016, 04:07 AM   #6
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Ubuntu, Devuan, OpenBSD
Posts: 1,365
Blog Entries: 3

Rep: Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562
tmux

When you first log in, you should run tmux. It will keep your session running even when disconnected.

Code:
tmux
Then if the ssh connection breaks, you can log in again and reattach tmux to join your session in progress.

Code:
tmux a
If you are on a train, or in another situation, where the connection breaks a lot, you can use a loop to reconnect. Just add your key to the agent and it works:

Code:
while ! ssh -t -p 22 -i ~/.ssh/somekey server.example.com 'tmux a || tmux';do sleep 2;done
Again, tmux will keep your session running so if there is a lot of output while you were gone, you will have to roll back in the tmux buffer as opposed to the terminal window itself. tmux has a lot of improvements over screen, but screen could be used in a similar manner though the options are different.
 
1 members found this post helpful.
Old 05-10-2016, 07:09 AM   #7
slac-in-the-box
Member
 
Registered: Mar 2010
Location: oregon
Distribution: slackware64-14.2
Posts: 208

Original Poster
Rep: Reputation: 79
I haven't tried mosh yet, as it wasn't included with slackware. Screen and Tmux are, and they both worked, and so I guess it doesn't matter--like emacs and vi--just pick one and go. As soon as I reached a prompt after ssh into remote server, I typed
Code:
root@myhost# screen
and new prompt appeared; Everything looked the same, and I typed
Code:
root@myhost# nohup make bzImage > makeout-bzimage &
The process ID appeared, and eventually finished with no hickups. Then I exited, and it said I exited screen. I exited again and closed ssh session.
I started a new session, and this time typed
Code:
root@myhost# tmux
and new prompt appeared, as well as a green status bar that visually let me know I was in tmux. Then I typed
Code:
root@myhost# nohup make modules > makeout-modules &
and I did have an interrupt in connectivity during this session. When I reconnected, I did the
Code:
root@myhost# tmux a
and the same window with green status bar appeared, with the command still running. It finished. I configured my system to use the new kernel, rebooted, and crossed my fingers. A few minutes later, I was into my system running a new kernel. Yeah!

Thanks LQ.
 
Old 05-10-2016, 12:09 PM   #8
sag47
Senior Member
 
Registered: Sep 2009
Location: Orange County, CA
Distribution: Kubuntu x64, Raspbian, CentOS
Posts: 1,845
Blog Entries: 36

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
If you're running inside of screen or tmux then you don't need to use nohup. Both are designed to maintain the tty when you get disconnected. So you can just reattach to the session when you log in again.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] remote ssh connection failed. staped Linux - Networking 8 04-14-2014 12:43 AM
Can't SSH to remote machine: Connection closed by remote host Avatar Linux - Networking 34 05-24-2013 10:28 AM
SSH connection to remote machine... harishkrishnan Linux - Networking 5 11-10-2007 01:35 AM
Remote Connection Using SSH sudheer.guduru Linux - Server 1 08-22-2006 06:05 AM
problems getting remote ssh/X connection working fabs Linux - Newbie 6 03-01-2004 11:24 PM


All times are GMT -5. The time now is 06:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration