Go Back   AnandTech Forums > Software > *nix Software

Forums
· Hardware and Technology
· CPUs and Overclocking
· Motherboards
· Video Cards and Graphics
· Memory and Storage
· Power Supplies
· Cases & Cooling
· SFF, Notebooks, Pre-Built/Barebones PCs
· Networking
· Peripherals
· General Hardware
· Highly Technical
· Computer Help
· Home Theater PCs
· Consumer Electronics
· Digital and Video Cameras
· Mobile Devices & Gadgets
· Audio/Video & Home Theater
· Software
· Software for Windows
· All Things Apple
· *nix Software
· Operating Systems
· Programming
· PC Gaming
· Console Gaming
· Distributed Computing
· Security
· Social
· Off Topic
· Politics and News
· Discussion Club
· Love and Relationships
· The Garage
· Health and Fitness
· Merchandise and Shopping
· For Sale/Trade
· Hot Deals
· Free Stuff
· Contests and Sweepstakes
· Black Friday 2013
· Forum Issues
· Technical Forum Issues
· Personal Forum Issues
· Suggestion Box
· Moderator Resources
· Moderator Discussions
   

Reply
 
Thread Tools
Old 01-21-2013, 09:06 PM   #1
Red Squirrel
Lifer
 
Red Squirrel's Avatar
 
Join Date: May 2003
Location: Canada
Posts: 25,450
Default 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~
486dx2 @66Mhz turbo, 8MB ram, 512MB HDD, sound blaster 16 + 2x cdrom, Trident 1MB video card @ 640*480, 56k high speed modem.
Red Squirrel is online now   Reply With Quote
Old 01-21-2013, 11:14 PM   #2
mundane
Diamond Member
 
Join Date: Jun 2002
Posts: 5,485
Default

..

Last edited by mundane; 01-31-2013 at 09:25 AM.
mundane is offline   Reply With Quote
Old 01-21-2013, 11:27 PM   #3
Jodell88
Diamond Member
 
Jodell88's Avatar
 
Join Date: Jan 2007
Location: Salamandastron
Posts: 6,068
Default

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
Jodell88 is online now   Reply With Quote
Old 01-22-2013, 09:13 AM   #4
Ken g6
Elite Member
 
Ken g6's Avatar
 
Join Date: Dec 1999
Location: Colorado
Posts: 8,345
Default

I think you guys might be over-thinking it. It sounds like he just needs "nohup".
__________________
Look for really BIG primes with TeAm AnandTech PrimeGrid!
Next race: May 20-28

vBulletin looking run down? Get your script fix here.
Ken g6 is online now   Reply With Quote
Old 01-22-2013, 02:52 PM   #5
Jodell88
Diamond Member
 
Jodell88's Avatar
 
Join Date: Jan 2007
Location: Salamandastron
Posts: 6,068
Default

Quote:
Originally Posted by Ken g6 View Post
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
Jodell88 is online now   Reply With Quote
Old 01-22-2013, 04:38 PM   #6
mv2devnull
Senior Member
 
Join Date: Apr 2010
Posts: 744
Default

"at now" is an alternative with more control on redirects.
mv2devnull is offline   Reply With Quote
Old 01-22-2013, 06:47 PM   #7
Red Squirrel
Lifer
 
Red Squirrel's Avatar
 
Join Date: May 2003
Location: Canada
Posts: 25,450
Default

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~
486dx2 @66Mhz turbo, 8MB ram, 512MB HDD, sound blaster 16 + 2x cdrom, Trident 1MB video card @ 640*480, 56k high speed modem.
Red Squirrel is online now   Reply With Quote
Old 01-23-2013, 05:44 AM   #8
Nothinman
Elite Member
 
Nothinman's Avatar
 
Join Date: Sep 2001
Posts: 30,672
Default

Quote:
Originally Posted by Ken g6 View Post
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.
__________________
http://www.debian.org
Nothinman is offline   Reply With Quote
Old 01-24-2013, 09:56 AM   #9
_Rick_
Platinum Member
 
Join Date: Apr 2012
Posts: 2,753
Default

If you're an admin, you can also use the service/daemon frame work of your distribution.
_Rick_ is online now   Reply With Quote
Old 01-24-2013, 06:35 PM   #10
TheRyuu
Diamond Member
 
Join Date: Dec 2005
Posts: 4,817
Default

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'
Code:
tmux -u new
Gets you a new tmux session.
Ctrl-A + D detaches you, then you can leave the ssh session.
Code:
tmux attach
Should be self explanatory

Last edited by TheRyuu; 01-24-2013 at 06:48 PM.
TheRyuu is offline   Reply With Quote
Reply

Thread Tools

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 On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 07:01 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.