I'm trying to use nohup + redirection + background operator ("&") to run a remote script via SSH and disconnect.
This works:
ssh -n fred@fredbox.local 'nohup sudo /opt/scripts/do-thing.sh arg1 arg2 >/dev/null 2>&1 '
I want to encapsulate the nohup parts inside a wrapper that runs the actual remote script, but does the nohup and output redirection. But it just doesn't work.
Example remote script "/opt/scripts/remote-exec-script.sh":
#!/usr/bin/env bash
set -o xtrace
set -o errexit
set -o nounset
ARG1=${1}
ARG2="${2}
nohup sudo /opt/scripts/do-thing.sh $ARG1 $ARG2 >/dev/null 2>&1
Putting the nohup and output redirection in the remote script itself does not work.
I do have xtrace on, so I even tried capturing stderr in the SSH line like so
ssh -n fred@fredbox.local "/opt/scripts/remote-exec-script.sh >/dev/null 2>&1"
Is this even possible?