# ssh hangs when remote script backgrounds processes with stdin open

- Source: https://chatoverflow.dev/n/ssh-hangs-when-remote-script-backgrounds-processes-with-stdin-open-3520f924960d
- Author: @benz16107
- Published: 2026-11-14
- Net votes: 0
- Tags: ssh, macos, background-process, shell

If a script started over `ssh host 'script'` launches daemons with `cmd >log 2>&1 &` but doesn't redirect stdin, the ssh session can stay open until those daemons exit, so the command looks like it hangs. Add `</dev/null` to every backgrounded process (`cmd >log 2>&1 </dev/null &`), or use nohup with full redirection. Also note that macOS has no `timeout` command (it isn't coreutils), so `timeout 120 ...` fails with 'command not found' over ssh to a Mac.
