Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We need to be able to create a way to reboot virtual machines in the lab every 20 minutes automatically.

Is there any way this can be done in vSphere 5?

share|improve this question
Can't you do that from system itself ? Like creating scheduled restart in windows/ cronjob in linux? Or it must be in lower lvl ? – Alan Kuras Apr 3 '12 at 5:23
No My Friend, Im Running vulnerable machine for metasploit practice. now ones that system exploit so it has to restart. i'm not available online all the time, so i want to manage something like automatically reboot my virtual machines in every 20 mints. – Ashish Apr 3 '12 at 5:38
Just a thought... have you considered the possibility that someone might escape the VM and take over the hypervisor? – Ladadadada Apr 3 '12 at 10:23
What is the reason for you to reboot an exploited machine? Do you mean rebuild a machine every 20 minutes? – Rilindo Apr 3 '12 at 13:05
@Rilindo If the exploit only resides in memory, than a reboot would fix. – JakeRobinson Apr 3 '12 at 19:46

I don't have access to vSphere now but it should be like this:

  1. Go to scheduled task (Home->...)
  2. Create new task changing VM power state
  3. Select virtual machine
  4. Select power operation option "Reset"
  5. Select Frequently
  6. Finish

Alternatively You can use vSphere CLI :

share|improve this answer
I'm Running vulnerable machine for metasploit practice. And I Created a online lab so any one can join and play with that machines. now ones that system exploited, So i have to restart the system. i'm not available online all the time, so i want to manage something like automatically reboot my virtual machines in every 20 mints – Ashish Apr 3 '12 at 9:24
is that the same effect as hitting the reset button or issuing a reset command through the OS? – Mauro Apr 3 '12 at 9:25
...I'm missing why the solution of resetting the machine isn't the same as resetting it periodically. Alternatively you should script a way to roll back the machine from snapshot every X minutes. Better than rebooting. – Bart Silverstrim Apr 3 '12 at 12:59

I would use a vSphere scheduled task for this, like Alan said.

  • "Power on": turns on the power
  • "Power off": turn off the power
  • "Shut down": tidy shutdown of the guest OS
  • "Suspend": tidy suspend of the guest OS
  • "Reset": power-cycle the guest (basically power-off then power-on)

In addition, I don't see any point in rebooting a broken machine, so you could also use non-persistent disks on it, so that when the VM reboots, it reverts back to a known good state. Otherwise rebooting a hacked machine just results in a hacked machine...

There is an obvious problem with a scheduled restart though: what happens if I connect to start testing my exploit at 13:59, and the restart is scheduled for 14:00?

share|improve this answer

Why don't you simply create a bat file

having code

shutdown -r -f -t 1200000 ;

and create a schedule to execute it

share|improve this answer
This relies on the machine being up and running, though. Much better to get VMWare to do it. – Dan Apr 3 '12 at 9:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.