Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to reboot one box from another, using the following command:

ssh 10.0.0.26 'reboot --force'

I expect this to block for a short while until the other box reboots, then return. What I see happening is no activity for a while, then if I press a key, I get "Write failed: Broken pipe".

The reboot of the other box works just as expected, but I'd like to clear up the output on the local box, ideally without just hiding it all in /dev/null.

I'm using OpenSSH 5.3p1 on Redhat 6.

Edit: I've foundmy own solution; I'll add this as an answer below. Seems I can't accept this just yet, though. I guess this is to give others a chance to come in with a better solution.

share|improve this question
    
A review of man reboot would suggest that using the force option precludes a normal shutdown for sshd - i.e. you're killing sshd and your client is (legitimately) notifying you. Hiding with redirection to /dev/null is the only way around the warning if you have to use the force option on the remote server. –  danlefree Nov 30 '10 at 15:41

3 Answers 3

You can schedule reboot instead of just rebooting immediately. Have a look at this post.

share|improve this answer
    
Scheduling reboot using shutdown gives very different behaviour to reboot --force. The latter reboots the system immediately, the former performs a nice friendly shutdown –  me_and Nov 30 '10 at 12:19
1  
@me_and: You can use "at" to schedule the system reboot using "reboot --force" or any other command. –  Khaled Nov 30 '10 at 12:29
up vote 0 down vote accepted

The line that works is as below:

ssh 10.0.0.26 'reboot --force >/dev/null &'

The final & tells the other system to run the command in the background. This alone isn't enough, however, as the ssh connection tries to stay open in case of any output. Hence sending stdout to null.

share|improve this answer

If you really do want to wait until the reboot is in full swing (e.g. ssh sessions killed), then poll the server once per second and quit if it failed to answer within 5 tries:

ssh -o ServerAliveInterval=1 -o ServerAliveCountMax=5 10.0.0.26 'reboot --force > /dev/null'

[A discussion here pointed me to the right parameters.]

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.