I am using the reboot -f
command remotely to force reboot a Unix machine.
The problem is that the ssh connection remains active for a long time which I don't know why?
I want to close the ssh connection immediately after rebooting the machine and return to my local shell.
How can i do that?
Note that the reboot command without -f
flag does not work.
|
|||||||||||||||||
|
The command
Since the SSH server process is dead, the SSH client won't die until the timer fires up. If you run
However, this is not reliable: depending on timing, step 3 might happen before step 2. Adding a timer makes this unlikely:
To be absolutely sure that the server side is committed to running |
|||||
|
I found a solution for this which might be helpful for others as well. I used the following command to close the connection right after starting the command attached to ssh:
I don’t exactly understand the reason why this command forces the connection to close but at least it was helpful for me. If anyone understands the logic behind it and why it kills the ssh connection; it would be nice if he/she explains it. |
||||
|
Try this command:
|
|||||||||||||||||
|
How about exit from ssh session and reboot system using next command:
After this just press Ctrl+C for terminate ssh. |
|||
|
Have you tried the following
I find that on some systems I worked on in the pass, the reboot command had some problems. Then again I can't find anything in the manpage of shutdown that would do the same as reboot with the -f flag. |
|||||
|