1

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).

1

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.

  • how to quit the within screen if I use the second solution? – upton May 7 '14 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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