in reply to Re^3: reboot a system (machine or server) multiple times with perl script
in thread reboot a system (machine or server) multiple times with perl script

Let me rephrase my question here again, i need to connect the system with ssh and then 1) the script should make the host to reboot 2) the script should ping for the Ip address after the reboot 3) once the host is back script should say host is up 4) then again script should start the reboot. is this possible ?

  • Comment on Re^4: reboot a system (machine or server) multiple times with perl script

Replies are listed 'Best First'.
Re^5: reboot a system (machine or server) multiple times with perl script
by choroba (Cardinal) on Mar 16, 2015 at 09:42 UTC
    No Perl in the game.
    #!/bin/bash ssh root@machine 'reboot' until ping -c1 machine ; do sleep 1; done ssh root@machine 'reboot'
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^5: reboot a system (machine or server) multiple times with perl script
by bitingduck (Deacon) on Mar 16, 2015 at 08:53 UTC

    yes, as I think a number of people have already said. You can probably do most of it with a shell script even, without Perl. You since you're on ubuntu, you can edit the /etc/rc.local file to launch your script at startup. You can then do your thing, write yourself a note on how many times you still want to reboot, then let the shell script move on to the next step and reboot. The reboot steps probably have to run as root, but the rest can probably run as anybody. I'd probably return a 1 or a 0 from the Perl script to tell the shell whether to reboot or just go along it's way.