I’m writing a simple script that creates a new VirtualBox VM, spins it up and then connects to it via SSH to execute some commands. The problem is, I have to wait for a certain amount of time for the VM to boot. Currently I just do a sleep 120 in my script to sleep for 2 minutes. However, instead of waiting for 2 minutes, I would like to get some sort of notification when the VM boots and is ready to accept SSH connections. Is that possible?
P.S.:
Solutions involving guest additions won’t work – the OS on the guest is vanilla CentOS 5.7, no guest additions installed.
You could replace the
sleep 120with something liketo just keep trying until you got through.