I’m currently trying to ssh into a remote machine and run a script, then leave the node with the script running. Below is my script. However, when it runs, the script is successfully run on the machine but ssh session hangs. What’s the problem?
ssh -x $username@$node 'rm -rf statuslist
mkdir statuslist
chmod u+x ~/monitor/concat.sh
chmod u+x ~/monitor/script.sh
nohup ./monitor/concat.sh &
exit;'
There are some situations when you want to execute/start some scripts on a remote machine/server (which will terminate automatically) and disconnect from the server.
eg: A script running on a box which when executed
I would use the following command:
@CKeven, you may put all those commands on one script, push it to the remote server and initiate it as follows:
Hope this works 😉
Edit:
You can also use
ssh user@host ‘screen -S SessionName -d -m “/path/to/executable”‘
Which creates a detached screen session and runs target command within it