VMware Cloud Community
Griff389
Contributor
Contributor
Jump to solution

Schedule a shutdown of the host

Hi all,

Is there a way, either on the host, or through Virtual Centre, that I can schedule a shutdown of a host ESX server? There doesn't seem to be an option in scheduled tasks for the host, only to change the power of a VM.

Regards

Carl

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
espi3030
Expert
Expert
Jump to solution

Good to hear! I copied my shutdown script to a newly created directory named SCRIPTS, then it is executed with ./PowerOff. Use with caution, because when launched there is no confirmation if this is what you want to do. It will immediately start shutting VM's off, the way it does that is it will attempt a graceful shutdown of all running VM's, if unsuccessfull it will then perform a hard poweroff. Basically it will pull the plug on the VM, after all VM's have been powered off it will issue a "shutdown -h now" to the host. You can modify this script with "vi" to reboot your esx hosts as well, just edit the line near the bottom that reads "shutdown -h now" to read either "reboot" or "shutdown -r now".

Here is a link for some help creating cron jobs -->

Hope this helps!

View solution in original post

0 Kudos
6 Replies
espi3030
Expert
Expert
Jump to solution

I have a shutdown script that will poweroff all your running VM's and then power off the ESX host. I haven't found a way to create a scheduled task within VirtualCenter but you should be able to create a cron job.

Hope this helps!

0 Kudos
Griff389
Contributor
Contributor
Jump to solution

Thanks for that. It sounds like a plan. Smiley Happy

Our datacentre needs to power cycle their systems so I want to shut it all down gracefully before hand. I'd thought of scheduling each VM to shutdown automatically, then login and shutdown the host manually, but this may help.

However, i've little experience of Linux, and so not sure how to get your script to a runable state. I've copied it to the host, but not sure what to do with it then. Smiley Happy

0 Kudos
espi3030
Expert
Expert
Jump to solution

Good to hear! I copied my shutdown script to a newly created directory named SCRIPTS, then it is executed with ./PowerOff. Use with caution, because when launched there is no confirmation if this is what you want to do. It will immediately start shutting VM's off, the way it does that is it will attempt a graceful shutdown of all running VM's, if unsuccessfull it will then perform a hard poweroff. Basically it will pull the plug on the VM, after all VM's have been powered off it will issue a "shutdown -h now" to the host. You can modify this script with "vi" to reboot your esx hosts as well, just edit the line near the bottom that reads "shutdown -h now" to read either "reboot" or "shutdown -r now".

Here is a link for some help creating cron jobs -->

Hope this helps!

0 Kudos
Griff389
Contributor
Contributor
Jump to solution

Thanks. I've got the script in a folder, so will take the easy route and RDP to my PC at work , then PTY to the ESX machine and run the script. All the VM's should shut down gracefully as they're all Windows Servers with VM tools installed. All but one, which is a linux machine, so i've no idea how that will shutdown (with a thud i'd expect). :smileylaugh:

At some point i'll take a look at CRON and have a play on our test esx server and figure it out.

Thanks again. :smileycool:

0 Kudos
Griff389
Contributor
Contributor
Jump to solution

spoke too soon. I PTY'd to my test server, logged in, su'd to root, then ran ./PowerOff and got

-bash: ./PowerOff: Permission denied

I guess i'm missing something, just need to figure out what.

0 Kudos
Griff389
Contributor
Contributor
Jump to solution

just to answer my own question. "chmod +x PowerOff" seemed to sort that message. Smiley Happy

0 Kudos