LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 07-10-2008, 03:04 AM   #1
tim-f
LQ Newbie
 
Registered: Jul 2008
Posts: 2

Rep: Reputation: 0
Question Running a process decoupled from SSH connection?


Hello,

I try to run a Java application on a remote Linux machine (debian 2.6.18-5-amd64) using SSH. The problem is that the task takes a lot of time to complete (typically more than 24h), and connection to the server is often lost during this time. I wonder if it is possible to run a process that is decoupled from my SSH session so that loosing the connection wouldn't terminate the process?

I have read about background processes, but this seems to be irrelevant in this case, because it just allows to run several processes in one session.

Thanks for any help!
 
Old 07-10-2008, 03:13 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
Run the program with nohup and place in background. See man nohup.

Alterntiavely, you can use screen. See man screen.
 
Old 07-10-2008, 03:14 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Running with nohup and putting the procecss in the background will prevent it from dying when you log off your ssh session.

The only problem with this is that you cannot interact with the process again using a terminal. If you need to do that then you can use GNU Screen:
  1. Log in with ssh
  2. Start a screen session by using the command screen
  3. Run your java process
  4. Press 'Control-a' then 'd'. This will detach the screen session from the terminal.
  5. Log off your ssh session
  6. At some later time, log back in with ssh
  7. Enter the command: screen -r to reconnect to the detached screen session
  8. If the process is still going, goto step 5, else continue to the next step.
  9. Have a cup of tea

Last edited by matthewg42; 07-10-2008 at 03:17 AM.
 
Old 07-10-2008, 03:20 AM   #4
tim-f
LQ Newbie
 
Registered: Jul 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Thumbs up Thanks

Thanks a lot, it is exactly what I was looking for!
 
Old 07-10-2008, 03:34 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Screen is an awesome program. IMO the key bindings are a little quirky and can be difficult to remember at first, but it's still really useful.

You can re-define the keys and change other settings using a .screenrc file in your home directory. For example, you can set a large scrollback buffer by adding this to your .screenrc file:
Code:
defscrollback 5000
 
  


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
running bash scripts over ssh connection babag Linux - Newbie 1 05-27-2008 11:07 PM
Howto get the output of a running process using ssh? agouz Linux - Software 3 12-26-2005 12:11 PM
running ssh connection into batch file jdonaldogg General 1 12-17-2005 10:25 PM
SSH connection termination during a running process... jayemef Linux - General 1 08-16-2005 11:41 AM
Please help easy questions, how do I stop a process from running in SSH? lexington Linux - Newbie 3 05-01-2004 12:03 PM


All times are GMT -5. The time now is 01:45 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration