LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-08-2006, 01:15 AM   #1
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495

Rep: Reputation: 85
Talking how to keep program running after closing ssh session


I am logged into a computer through ssh. I would like to run a program and have it keep running after I log out. How can I do that?
 
Old 08-08-2006, 01:25 AM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
One means of doing this is probably a program called screen. There are surely other ways but this is quite an easy one; screen can be thought as a virtual terminal, so what you get visually is that you can start a program using screen, then (put it in the background if you like and) "detach" it after which it keeps running even if you log out/close your ssh connection. When you come back, you can "reattach" it again and have control over the program - it won't die when you close the connection.

Read more from google, search LQ etc...and make sure you've got screen installed
http://jmcpherson.org/screen.html has some quick info on how to use this..

Last edited by b0uncer; 08-08-2006 at 01:27 AM.
 
1 members found this post helpful.
Old 08-08-2006, 01:45 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If you don't need to re-attach later, you could also use "nohup".

Last edited by jschiwal; 08-08-2006 at 06:56 AM. Reason: fixed typo
 
1 members found this post helpful.
Old 08-08-2006, 02:27 AM   #4
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
fakie_flip I've edited the thread title to better reflect your problem.
 
Old 08-08-2006, 06:17 AM   #5
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
I have used screen for just this reason. It works very well. It took me a bit to understand the key sequence to detach though. Press and hold ctrl and hit the a key, Then press the d key to detach. The ctrl a tells it the next key is a command and the d is for detach. That should help you a little bit.

 
Old 08-09-2006, 07:11 AM   #6
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,637

Rep: Reputation: Disabled
Possibly stupid question as I don't use ssh: Why not simply use a <command &> and all should be well?
 
Old 08-09-2006, 08:11 AM   #7
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
I have never tried this but I think if he logs out it will kill the command. I THINK being the key words there.

 
Old 08-09-2006, 08:15 AM   #8
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,637

Rep: Reputation: Disabled
Umm, doesn't the &-operator detach the process from the console? When you use it and list the processes with "ps ax" or "top" they have their own PID and potter about in the background. But I'm no expert either .
 
Old 08-09-2006, 08:21 AM   #9
rahulk
Member
 
Registered: Mar 2006
Posts: 110

Rep: Reputation: 16
Quote:
Originally Posted by JZL240I-U
Umm, doesn't the &-operator detach the process from the console? When you use it and list the processes with "ps ax" or "top" they have their own PID and potter about in the background. But I'm no expert either .

The & puts the command in the backgroud. The command nohup detaches the process from the terminal. If the job is put as a background process then on exiting the console, the parent PID will change to 1 but the terminal will remain. Hence a process can be kept running either by putting it as a background job or by nohup command.
 
Old 10-09-2011, 01:37 PM   #10
vsluzky
LQ Newbie
 
Registered: Oct 2011
Posts: 1

Rep: Reputation: Disabled
The solution that worked for me: nohup ... &

Start your <command-with-parameters> as:
nohup <command-with-parameters> &
 
Old 11-03-2011, 09:33 AM   #11
u4david
LQ Newbie
 
Registered: Jan 2008
Posts: 6

Rep: Reputation: 0
Use screen

log in ssh
type screen
use ssh shell
detach screen
log out


learn how to use screen
 
  


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
SSH Slow Response/Session Closing FourierXForm Linux - Networking 3 08-07-2006 10:56 AM
LXer: Setting up RAID-1 mirroring on a running remote Linux system over ssh session LXer Syndicated Linux News 0 06-20-2006 11:03 PM
closing SSH session without killing the SFTP transfer on the remote machine stevec Linux - Software 2 04-20-2006 06:13 PM
How to run a program in an ssh session that will run after you close out the session? dr_zayus69 Linux - Networking 5 03-05-2006 08:15 PM
Running Program Through SSH windisch Linux - General 6 10-04-2005 07:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:11 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
Open Source Consulting | Domain Registration