VMware Cloud Community
aarm
Contributor
Contributor

Scheduling A VM to Pause

A standalone ESXi host running v 6.7 Update 2 is being accessed by many users who can start, pause or shutdown any VM.  The problem is that they do not shutdown or pause VMs as they should after finishing work and the host nearly always reaches near max RAM usage and I end up asking people to pause or shutdown VMs they don't use so that memory is released for starting another VM that is needed.

I thought there might be some way of scheduling a pause of a VM for example every early morning so that the host starts every morning with only the few VMs that need to be running 24x7.  A day's use never reaches max RAM use so this seems to be a way out if possible.

Has anyone any suggestions to help?

Thank you all.

0 Kudos
4 Replies
lamw
Community Manager
Community Manager

Depending on what platform (Windows vs Linux), you'd create a scheduled job that would run some script that calls into ESXi API to perform the pause or suspend. This assumes you've got a licensed ESXi host that is NOT using Free ESXi license or else the option is a bit more limited. 

PowerCLI is typically a popular tool due to its ease of use and now multi-platform support that can be used to create a small script that does exactly what you're looking for and then just needs to be scheduled to run based on your desired date/time

0 Kudos
aarm
Contributor
Contributor

Thank you for the reply.  Not experienced at all with PowerCLI but willing to read and learn.  Using licensed ESXi.  Could you point me to where to read and/or an example?  Is the job inside each VM?

Thanks for your help.

0 Kudos
lamw
Community Manager
Community Manager

Suspend-VM cmdlet is what you'll want to use https://developer.vmware.com/docs/powercli/latest/vmware.vimautomation.core/commands/suspend-vm/#Def... and you can see from example, its as easy as getting the VM and "piping" output (similiar to UNIX/Linux commands) into another cmdlet. If you're new to PowerCLI, search online for examples and read up on how it works. From there, you would schedule this script on a desktop or bastion system. For Linux, it could be cron and for Windows it would be windows task scheduler and this is done outside of your VMs, so you set it up once and it'll handle all VMs that you wish to perform this scheduled task

0 Kudos
aarm
Contributor
Contributor

Many thanks indeed.  Struggling to find time but will do and give feedback in case it is useful for others as well.

0 Kudos