Issue reboot command with remote execution returns exit status 255

On Foreman/Katello 3.3/4.5 and I have noticed that if I send the command reboot with remote execution it returns exit status 255. I expected it to return 0 since the command worked and machine was rebooted.

There’s a special template for that. Otherwise the host just breaks the connection which is interpreted as a failure. If you don’t use that template, we have no way of knowing that the host was supposed to do that.

Is this what you mean by using a template?

I guess an option is to also use “shutdown -r” instead of reboot in remote execution since I guess that is all the template is doing.

shutdown -r +1 to be exact. shutdown -r and reboot are effectively the same. The delay of one minute prevents the interruption of the current connection.

“shutdown -r” defaults to 1 minute delay, at least on my CentOS 7 and AlmaLinux 8/9 machines “shutdown -r now” is the same as reboot I think.

# date;shutdown -r
Fri Oct  7 11:09:26 UTC 2022
Shutdown scheduled for Fri 2022-10-07 11:10:26 UTC, use 'shutdown -c' to cancel.
#shutdown -c
# date;shutdown -r +1
Fri Oct  7 11:09:48 UTC 2022
Shutdown scheduled for Fri 2022-10-07 11:10:48 UTC, use 'shutdown -c' to cancel.