What is a proper way of switching the servers and VMs off and on for power outage? [closed]
Want to improve this question? Update the question s开发者_JS百科o it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this questionmy organisation have two physical servers and some VMs. Currently when there is a pre-scheduled power outage, I use a script I wrote to loop through all VMs scheduling a shutdown command to all VMs and the servers. For example,
ssh root@${VMS[$i]} 'echo "shutdown -h now" | at 05:00am Mar 31'
Then I restart the machines when I am back to the office in the morning.
Is this the appropriate way of doing the auto shutdown? Do you do it differently? Thanks in advanced.
For starters, the shutdown command can take a time directly itself, you don't need to use at for that (see http://www.computerhope.com/unix/ushutdow.htm).
Beyond that, though, I don't see anything wrong with this approach, provided that your environment can tolerate those servers being offline potentially longer than necessary (i.e. if a power outage lasts from 9-10 pm, but you don't start them back up until 8 am the next morning, that's 10 hours longer that they were off than they really needed to be), which your description seems to suggest is the case. In this environment, I don't think I would do anything differently, beyond also scheduling the host computer to shutdown a couple of minutes after the VMs are scheduled to do so.
精彩评论