SSH does not exit the command line

I ssh to another server and run a shell script like this nohup ./script.sh 1>/dev/null 2>&1 &

Then type exit to exit the server. However, it just freezes. The server is Solaris.

How can I exit normally without freezing?

Thank.

+3
source share
4 answers

I assume this script is long. In this case, you need to separate the process from the terminal that you want to close when you end the ssh session.

In fact, you have already completed most of the work by reassigning both stdout, and stderrto /dev/null, however you have not done so for stdin.

I used a test case:

ssh localhost
nohup sleep 10m &> /dev/null &
^D 
# hangs

While

ssh localhost
nohup sleep 10m &> /dev/null < /dev/null &
^D 
# exits

-, gnu screen, , .

, , script , ? :.

ssh user@host script.sh
+7

SSH, screen . , ; , .

script.sh, , , .

+1
sh -c ./script.sh &
0

:

~.

ssh.

0

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


All Articles