Remote ssh command not returning

I run ssh somehost "service XXX restart" and the shell freezes.

The nodeJS service and I see express is listening on port ... print, which I did in server.js , and that it does not return at the prompt, it just hangs.

I tried nohup and, but that didn't help. What else can I try?

+4
source share
2 answers

it turns out that using -t fixes the problem.

ssh -t root@somehost "service XXX restart" does not hang.

Other suggestions from comments that may solve this problem:

  • node myScript.js & disown
  • exec node myScript.js &
+6
source

Using ssh -t does not freeze, but also terminates the remote process.

What works for me is to simply start the remote process in the background, as shown below:

 ssh somehost /path/to/some/script augment1 augment2 & 
0
source

Source: https://habr.com/ru/post/1500115/


All Articles