Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:… – instanceof me Jul 19 '13 at 12:49
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 '14 at 9:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .