|
|
 |
01-21-2013, 09:06 PM
|
#1
|
|
Lifer
Join Date: May 2003
Location: Canada
Posts: 21,219
|
How to start an app within a SSH session and have it continue to run if I leave?
If I do something like:
./appname &
It runs in the background. yet, if I close the SSH console I ran that from, the app or script terminates. How do I make it so it does not terminate?
I had the impression it already worked that way, but it just so happened that the console I've been doing this stuff from always stayed open on my server. I accidentally closed it, and all hell broke loose. I can't seem to get everything started again without having to keep a SSH session active somewhere or restarting the whole server (all that stuff is in the rc.local file). Is there a way to do this?
__________________
~Red Squirrel~
That if you confess with your mouth, "Jesus is Lord," and believe in your heart that God raised him from the dead, you will be saved. For it is with your heart that you believe and are justified, and it is with your mouth that you confess and are saved. Romans 10:9-10
|
|
|
01-21-2013, 11:14 PM
|
#2
|
|
Diamond Member
Join Date: Jun 2002
Posts: 5,474
|
..
Last edited by mundane; 01-31-2013 at 09:25 AM.
|
|
|
01-21-2013, 11:27 PM
|
#3
|
|
Diamond Member
Join Date: Jan 2007
Location: Salamandastron
Posts: 3,908
|
I would go with tmux over screen, but the same principle is behind the software.
__________________
“Defend the weak, protect both young and old, never desert your friends. Give justice to all, be fearless in battle and always ready to defend the right." - The law of Badger Lords
|
|
|
01-22-2013, 09:13 AM
|
#4
|
|
Elite Member
Join Date: Dec 1999
Location: Colorado
Posts: 7,378
|
I think you guys might be over-thinking it. It sounds like he just needs "nohup".
|
|
|
01-22-2013, 02:52 PM
|
#5
|
|
Diamond Member
Join Date: Jan 2007
Location: Salamandastron
Posts: 3,908
|
Quote:
Originally Posted by Ken g6
I think you guys might be over-thinking it. It sounds like he just needs "nohup".
|
I never heard of this command.
__________________
“Defend the weak, protect both young and old, never desert your friends. Give justice to all, be fearless in battle and always ready to defend the right." - The law of Badger Lords
|
|
|
01-22-2013, 04:38 PM
|
#6
|
|
Senior Member
Join Date: Apr 2010
Posts: 664
|
"at now" is an alternative with more control on redirects.
|
|
|
01-22-2013, 06:47 PM
|
#7
|
|
Lifer
Join Date: May 2003
Location: Canada
Posts: 21,219
|
Interesting, I will give nohup that a try, thanks! Also forgot about the at command, that would work too.
Also through further experimenting I noticed if I do it with & and exit the console gracefully by typing exit, I'm ok. It's if I just X out of it.
__________________
~Red Squirrel~
That if you confess with your mouth, "Jesus is Lord," and believe in your heart that God raised him from the dead, you will be saved. For it is with your heart that you believe and are justified, and it is with your mouth that you confess and are saved. Romans 10:9-10
|
|
|
01-23-2013, 05:44 AM
|
#8
|
|
Elite Member
Join Date: Sep 2001
Posts: 30,658
|
Quote:
Originally Posted by Ken g6
I think you guys might be over-thinking it. It sounds like he just needs "nohup".
|
With that you lose control of the process, with screen or tmux you can resume the session and still interact with it if necessary.
|
|
|
01-24-2013, 09:56 AM
|
#9
|
|
Golden Member
Join Date: Apr 2012
Posts: 1,502
|
If you're an admin, you can also use the service/daemon frame work of your distribution.
|
|
|
01-24-2013, 06:35 PM
|
#10
|
|
Diamond Member
Join Date: Dec 2005
Posts: 4,787
|
I like tmux. Switched from screen, you can do a little more than screen but the main thing is the configuration is likely going to be far easier.
Code:
set-option -g prefix C-a
bind-key C-a last-window
bind-key a send-prefix
set -g default-terminal "screen-256color"
set -g status-bg black
set -g status-fg white
set -g status-left-length 25
set -g status-right-length 50
set -g status-left '#[fg=green,dim][ #[fg=green,bold,nodim]#(whoami)#[fg=green,dim,nobold]@#[fg=green,bold,nodim]#H #[fg=green,dim,nobold]] #[default]'
set -g status-right '#[fg=green,dim][ #[fg=green,bold,nodim]#(cut -d " " -f 1-3 /proc/loadavg) #[fg=green,dim,nobold]] [ #[fg=green,bold,nodim]%Y-%m-%d %I:%M %p #[fg=green,dim,nobold]]'
set -g base-index 1
set-window-option -g utf8 on
set-window-option -g window-status-current-fg white
set-window-option -g window-status-current-format '#[fg=red,bold](#[fg=white,bold]#I:#W#F#[fg=red,bold])'
set-window-option -g window-status-fg green
set-window-option -g window-status-format '#I:#W#F'
Gets you a new tmux session.
Ctrl-A + D detaches you, then you can leave the ssh session.
Should be self explanatory
Last edited by TheRyuu; 01-24-2013 at 06:48 PM.
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:35 AM.
|