I want to run some script through ssh and detach it, so it run even after ssh session is closed. I need to do this with sudo.
I can run some script but I am not able to detach it. I tried following commands:
ssh 10.0.139.120 -t "sudo -b nohup some_script"
and
ssh 10.0.139.120 -t "sudo nohup some_script &"
Neither of above worked. Every time I get communicate "Connection to 10.0.139.171 closed." and no process is running on server.
I have also tried to do it with screen:
ssh 10.0.139.120 -t "sudo screen -S script -md some_script"
It did not work either, even though command works when I enter it on server locally. How can I do it then?
sudo
? I’d try:ssh 10.0.139.120 -t 'sudo sh -c "nohup some_script &"'
– dessert Jan 18 '19 at 12:40