Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Leaving SSH Process Running

Leaving SSH Process Running
Thread Tools
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Aug 5, 2003, 05:03 PM
 
Hi, I just set up an internet radio server using Shoutcast and FreeBSD. I want to login from my Mac OS X machine and be able to start a process on the FreeBSD machine and leave it running after I close the SSH connection. How can I do it?
     
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Aug 5, 2003, 05:33 PM
 
Originally posted by davecom:
Hi, I just set up an internet radio server using Shoutcast and FreeBSD. I want to login from my Mac OS X machine and be able to start a process on the FreeBSD machine and leave it running after I close the SSH connection. How can I do it?
Have you even tried?

Tips:

'&' at the end of a command will launch it in the background:

tar -zxf file.tgz &

ctrl-z while running a command will suspend the command and put you at the command line. From that point, you can either 'bg' to put the command in the background, or you can 'fg' to put the command in the foreground.

'nohup' at the beginning of a command will ensure that the process will ignore a SIGHUP, which makes it slightly more difficult to kill. The process will stay running, even if your terminal connection just dies:

nohup fink update-all

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
Aug 6, 2003, 10:15 AM
 
Originally posted by davecom:
Hi, I just set up an internet radio server using Shoutcast and FreeBSD. I want to login from my Mac OS X machine and be able to start a process on the FreeBSD machine and leave it running after I close the SSH connection. How can I do it?
Try screen instead.

You can start a screen session remotely after logging in via ssh with the simple command 'screen'. Then you can execute whatever commands you like (as in a regular shell). Then you can detach the screen session with a Ctrl-A-D and logout.
You can re-attach to the same screen session either locally or remotely with a simple 'screen -r' and everyhting will be exactly as you left it. You can also start multiple screen sessions.

I use it all the time for starting long running commands from home like backups and database indexing (can take hours even days).

Example:

ssh root@someserver
screen
su - indexer
sh runindexer.sh
Ctrl-A-D
exit

Some time and some place later:

ssh root@someserver
screen -r
do some stuff
Ctrl-A-D
exit

Note: user indexer does not have a login shell.

To end a screen session simply exit from within it. If you forget to de-attach the session before leaving home (I often do this) just type 'screen -d' then 'screen -r'.

I think it comes with Jaguar, it is also available via fink.

See:
http://www.macosxhints.com/article.p...ery=gnu+screen
for more info.
-DU-...etc...
     
davecom  (op)
Mac Elite
Join Date: Jan 2001
Location: New York
Status: Offline
Reply With Quote
Aug 6, 2003, 10:20 AM
 
Thanks for the help people. It's all good now.
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:30 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2