How can I use ssh to run a command on a Unix machine and exit before the command completes?
For instance, if I type
ssh localhost 'sleep 60 &'
ssh hangs on my terminal until sleep completes, even though sleep is run in the background.
|
feedback
|
|
SSH has an -f swtich which does exactly the same as using nohup on your client but makes it possible that ssh asks for a password. Use it like that:
But: SSH will still live in background, so if you should down the client before the command an the server finished, it will be aborted. If you want the ssh connection to be closed after executing the command you can use screen on ther server side:
| |||||||||||
feedback
|
|
Use nohup, stdout/stderr redirection, and run the command in the background:
EDIT: Or even better, just use the ssh's -f parameter:
| ||||
feedback
|
|
Or after login in using | |||
|
feedback
|
&outside of the quotes. – Brad Gilbert Jul 19 '09 at 18:20