Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

by choroba (Cardinal)
on Mar 13, 2015 at 11:26 UTC ( [id://1119942]=note: print w/replies, xml ) Need Help??


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

Once the system reboots, the script is no longer running. You have to leave some kind of persistent information for the system to iterate the next step, probably create a file somewhere. You also have to configure the system to check for the information upon start-up.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re^3: reboot a system (machine or server) multiple times with perl script

Replies are listed 'Best First'.
Re^4: reboot a system (machine or server) multiple times with perl script
by irthiza90 (Novice) on Mar 16, 2015 at 07:36 UTC

    yeah, its kind of impossible until i modify my system to execute other commands in the startup, but is there a way to make the system or server sleep for say few secs and later pinging it to confirm that its active ? Please help, Thank you,

      you know applying it using perl script, if yes please help Thank you,

Re^4: reboot a system (machine or server) multiple times with perl script
by irthiza90 (Novice) on Mar 16, 2015 at 07:52 UTC

    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 ?

      No Perl in the game.
      #!/bin/bash ssh root@machine 'reboot' until ping -c1 machine ; do sleep 1; done ssh root@machine 'reboot'
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1119942]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found