Wait for linux machine to be rebooted
- by Theo
I have a small script to install on my remote machine an update.
I would like to reboot the machine remotely and if it is rebooted, continue with some more commands.
What I currently do is:
ssh root@myMachine << COMMANDS_ISSUED
###... Tasks
init 6
COMMANDS_ISSUED
sleep 180s
ssh root@myMachine << POST_REBOOT_COMMANDS
###.... More stuff
POST_REBOOT_COMMANDS
Is there a more elegant way to do it? Like pinging the machine all 5 seconds up to a maximum of 4 minutes?
I play with a few linux machines which have different boot up times and if my script would continue immediately after reboot, this could safe quite some time for me. (Note: I don't want to parallelize execution over all machines as I want to see for each machine if everything worked fine)