image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #9  
Old June 10th, 2008, 02:44 PM
ElDiabloConCaca's Avatar
U.S.D.A. Prime
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 9,905
Thanks: 2
Thanked 61 Times in 57 Posts
ElDiabloConCaca has a spectacular aura aboutElDiabloConCaca has a spectacular aura aboutElDiabloConCaca has a spectacular aura about
Quote:
Originally Posted by Viro View Post
As far as I know, that will not work if you log out of SSH before the copy is complete.
The background copy will work and will continue to completion (or error), but the "fg" command will not, since your new SSH session has no background processes. In essence, you cannot "log back into" an SSH session you've already logged out of. If you SSH back into the machine after doing both the background copy and log out, then you're pretty much relegated to simply waiting until the copy finishes, or killing it with a kill command.

You can use the UNIX/Linux utility "Screen" to get around this. A little complicated to learn, but well worth it if you intend on performing actions like this often.
__________________
Power Macintosh G4/500MHz "Yikes!" 10.4.11 Server • 1024MB • 3 x 120GB + 320GB • DVR-111D • 2 x Radeon 7000 PCI • 2 x 17" CRT
MacBook 2.0GHz Core 2 Duo - White 10.5.5 • 2048MB • 80GB • CD-RW/DVD-ROM
iPod Photo 60GB • iPod nano 1GB • AT&T DSL 6Mb/768k
http://www.jeffhoppe.com
Reply With Quote
  #10  
Old June 10th, 2008, 03:03 PM
Viro's Avatar
Registered User
 
Join Date: Nov 2003
Location: Oxford, UK
Posts: 2,489
Thanks: 0
Thanked 1 Time in 1 Post
Viro will become famous soon enoughViro will become famous soon enough
Is that really true? I remember running some build scripts through SSH and I remember postfixing the build command with & hoping to make it run in the background when I logged out. Imagine my disappointment when the very next day I logged in to see that the build had stopped where I logged out.
Reply With Quote
  #11  
Old June 10th, 2008, 03:18 PM
ElDiabloConCaca's Avatar
U.S.D.A. Prime
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 9,905
Thanks: 2
Thanked 61 Times in 57 Posts
ElDiabloConCaca has a spectacular aura aboutElDiabloConCaca has a spectacular aura aboutElDiabloConCaca has a spectacular aura about
Strange... we just tried it here with a bash shell script that looks like this:
Code:
#!/bin/sh
sleep 15
/usr/bin/dostuff.php
...which has a call to the program "dostuff.php" which is NOT backgrounded (all it does is mail a simple email to me). We then executed the script remotely via an SSH session, logged out within the 15 second window the script gave us, then monitored the process from a different machine. The script ran to completion, and I got the email.
__________________
Power Macintosh G4/500MHz "Yikes!" 10.4.11 Server • 1024MB • 3 x 120GB + 320GB • DVR-111D • 2 x Radeon 7000 PCI • 2 x 17" CRT
MacBook 2.0GHz Core 2 Duo - White 10.5.5 • 2048MB • 80GB • CD-RW/DVD-ROM
iPod Photo 60GB • iPod nano 1GB • AT&T DSL 6Mb/768k
http://www.jeffhoppe.com
Reply With Quote
  #12  
Old June 10th, 2008, 03:30 PM
ElDiabloConCaca's Avatar
U.S.D.A. Prime
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 9,905
Thanks: 2
Thanked 61 Times in 57 Posts
ElDiabloConCaca has a spectacular aura aboutElDiabloConCaca has a spectacular aura aboutElDiabloConCaca has a spectacular aura about
Just thought of a situation where logging out would kill a background process, and that's precisely what you're describing, Viro... if you have a process that reads from stdin or outputs to stdout, then you MUST redirect stdin and stdout to somewhere else (files, maybe), because when you log out, stdin and stdout pipes are closed, and then the program would fail.

Since compilers like cc and gcc output to stdout and stderr by default, when you log out, then next write to stdout or stderr would fail, and bring the script to a screeching halt.

If you re-route stdin and stdout (and, possibly, stderr) early in the script, backgrounding your compile script then logging out should allow it to continue running.
__________________
Power Macintosh G4/500MHz "Yikes!" 10.4.11 Server • 1024MB • 3 x 120GB + 320GB • DVR-111D • 2 x Radeon 7000 PCI • 2 x 17" CRT
MacBook 2.0GHz Core 2 Duo - White 10.5.5 • 2048MB • 80GB • CD-RW/DVD-ROM
iPod Photo 60GB • iPod nano 1GB • AT&T DSL 6Mb/768k
http://www.jeffhoppe.com
Reply With Quote
  #13  
Old June 11th, 2008, 12:47 AM
Viro's Avatar
Registered User
 
Join Date: Nov 2003
Location: Oxford, UK
Posts: 2,489
Thanks: 0
Thanked 1 Time in 1 Post
Viro will become famous soon enoughViro will become famous soon enough
Oh cool, that's probably it. I should have redirected output to a file somewhere. I never thought of that!
Reply With Quote
  #14  
Old June 11th, 2008, 05:04 AM
mvcube's Avatar
Mac newbie
 
Join Date: Mar 2008
Location: Wehrheim, Germany
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
mvcube is on a distinguished road
You have to use the "nohup" command to detach the cp process from the terminal. "man nohup" will tell you more.

"nohup" means "do not react on the HUP (hang up) signal!".

The output will be redirected automatically to a file named "nohup.out".
__________________
Marcus,
Wehrheim Germany

http://www.mvcsys.de
Reply With Quote
  #15  
Old June 11th, 2008, 05:49 AM
Giaguara's Avatar
Chmod 760
 
Join Date: Nov 2002
Location: ~
Posts: 7,539
Thanks: 0
Thanked 8 Times in 8 Posts
Giaguara has a spectacular aura aboutGiaguara has a spectacular aura about
And you could use cpmac instead of cp to also copy the resource forks over.
__________________
MacBook Pro + Mac mini | Newton 2000 | @Work : Dell D620 & 2x20" + a lot of Macs | Workstation, VC & Fusion
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do.
~ Samuel Clemens | Rants | Photos
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 01:35 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.