How do I reboot over a ssh connection without a return code of -1?
Use the shutdown
command.
shutdown --reboot +1 "System is going down for reboot in 1 minute"
I suspect the reason reboot
doesn't work is because it requires a tty. You could try running it with a background tty, but the shutdown
command has everything you need, including cancelling -- as it says in response:
Shutdown scheduled for Thu 2018-02-22 15:19:33 MST, use 'shutdown -c' to cancel.