Why does my remote host return an error code of -1 when I use the reboot () function?

Local host environment: CentOS 7, Python 3.5.1, Fabric3 (1.11.1.post1)
Remote Host Environment: CentOS 7

fibfile:

def fuc(): reboot() 

bash:

 fab -f fibfile.py -H host -u root -p password 

The remote host rebooted, but returns fatalError:

 sudo() received nonzero return code -1 while executing 'reboot'! 

Now I use warn_only to prevent the crash:

fabfile:

 def test(): with settings(warn_only=True): reboot() 
+5
source share
3 answers

I find a similar question when use issible: link

I think the correct answer is correct:

reboot shuts down the server so quickly that the server breaks the SSH connection.

shutdown -r now returns the same fatal error:

sudo () received a non-zero return code of -1 when executing 'shutdown -r now'!

shutdown -r +1 Return success:

out: shutdown scheduled for Mon 2016-05-23 14:16:48 UTC, use "shutdown -c" to cancel.

But shutdown can delay at least one minute. Therefore, we can only wait a minute or ignore the error.

+4
source

I am having a problem with some new virtual machines. I think they closed too quickly, as John Stark said.

To fix this, I ignore an error and warning like this.

 with settings(hide('warnings'), warn_only=True, ): sudo("shutdown -r now") 
+3
source

You can put a shell session in the background, which sleeps for 1 second, and then runs the reboot command. Should be done without using the nohup command due to the nohup issue . I am using tmux ...

 reboot(command='tmux new-session -d "sleep 1; reboot;"') 
+1
source

All Articles