Skip to content

Instantly share code, notes, and snippets.



Last active Apr 22, 2021
What would you like to do?
rex reboot
use Rex -feature => [qw(1.4 exec_autodie)];
use Rex::Commands::SimpleCheck;
sayformat "[%h]>\t%s";
task 'reboot', sub {
my $server = connection->server;
my $port = Rex::Config->get_port( server => $server ) || 22;
Rex::Logger::info('uptime before');
say run 'uptime';
run 'reboot';
Rex::Logger::info('Waiting for shutdown...');
while ( is_port_open $server, $port ) {
sleep 1;
Rex::Logger::info('Waiting for SSH to come back...');
while ( !is_port_open $server, $port ) {
sleep 1;
Rex::Logger::info('uptime after');
say run 'uptime';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment