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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-08-2006, 01:15 AM
|
#1
|
Senior Member
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495
Rep:
|
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?
|
|
|
08-08-2006, 01:25 AM
|
#2
|
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131
Rep:
|
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.
|
08-08-2006, 01:45 AM
|
#3
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
08-08-2006, 02:27 AM
|
#4
|
LQ Guru
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298
Rep:
|
fakie_flip I've edited the thread title to better reflect your problem.
|
|
|
08-08-2006, 06:17 AM
|
#5
|
Senior Member
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Rep:
|
|
|
|
08-09-2006, 07:11 AM
|
#6
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,637
Rep:
|
Possibly stupid question as I don't use ssh: Why not simply use a <command &> and all should be well?
|
|
|
08-09-2006, 08:11 AM
|
#7
|
Senior Member
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Rep:
|
|
|
|
08-09-2006, 08:15 AM
|
#8
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,637
Rep:
|
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 .
|
|
|
08-09-2006, 08:21 AM
|
#9
|
Member
Registered: Mar 2006
Posts: 110
Rep:
|
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.
|
|
|
10-09-2011, 01:37 PM
|
#10
|
LQ Newbie
Registered: Oct 2011
Posts: 1
Rep:
|
The solution that worked for me: nohup ... &
Start your <command-with-parameters> as:
nohup <command-with-parameters> &
|
|
|
11-03-2011, 09:33 AM
|
#11
|
LQ Newbie
Registered: Jan 2008
Posts: 6
Rep:
|
Use screen
log in ssh
type screen
use ssh shell
detach screen
log out
learn how to use screen
|
|
|
All times are GMT -5. The time now is 09:11 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|