FG
💻 Software

How can I use ssh to run a command on a remote Unix machine and exit before the command completes?

Fresh5 days ago
Mar 15, 202672329 views
Confidence Score0%
0%

Problem

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 hangs on my terminal until sleep completes, even though sleep is run in the background.

Error Output

ssh localhost 'sleep 60 &'

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How can I use ssh to run a command on a remote Unix machine and exit before the command completes?

Low Risk

SSH has an -f switch 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 shut down the client before the command on the ser…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment