Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a script on a mac mini server that slowly downloads a multi-gigabyte file. I would like to launch this script via SSH from another (linux) server with ssh mac-server 'nohup /path/to/script arguments' but immediately kill the SSH connection as soon as I know that the script has been successfully launched. Once it is launched, the SSH connection doesn't serve any useful purpose, systematically fails somewhere during the downloads, and blocks the execution on the linux server.

I can't just do ssh -f or ssh & because I need the command to fail on the linux server if the script doesn't launch (or if the mac is not reachable).

share|improve this question
    
Posted with more details and sample reproduction code on ServerFault: serverfault.com/questions/524738/… –  instanceof me Jul 19 '13 at 12:49

1 Answer 1

up vote 1 down vote accepted

This question has been detailed and anwsered on ServerFault.

To sum up, 2 solutions were found:

  1. Use nohup to launch the asynchronous task + close file descriptors:

    exec 0>&- # close stdin
    exec 0<&- 
    exec 1>&- # close stdout
    exec 1<&- 
    exec 2>&- # close stderr 
    exec 2<&- 
    
  2. Use screen -d -m to launch asynchronous task. It can then be checked (with screen -ls) or reattached at a later time.

share|improve this answer
    
how to quit the within screen if I use the second solution? –  upton May 7 at 9:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.