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

I have a Mac mini running Mavericks server. I installed the Atmail server + webmail vm [a linux centos distribution] in VMware Fusion Professional 6 with the VMware Tools addon. It works flawlessly. I've set it to start on boot and that works very reliably. However I've been looking for a way to also safely and gracefully shut it down whenever OS X shuts down for whatever reason. The Mac is connected to a UPS and configured to perform an automatic shutdown in case the battery starts running low so that's no additional problem.

Now the first thing I did was to go into Fusion's prefs and select "Power off the vm" when closing it. However I noticed that for some arcane reason closing the vm window would actually forcibly power off the vm: so then I found this post that showed me how to change the default power options and I managed to have the vm cleanly shutdown when closing its window or quitting Fusion altogether. At this point I was hoping to have solved the problem but as it turns out upon invoking system shutdown OS X doesn't wait for the vm to shutdown and terminates Fusion before it has a chance to do so. At this point I started looking for a way to automate the process of shutting down the guest os via some advanced setting but had no luck in doing so. That's when I found a command to shut the vm down: vmrun and it worked. The only thing left was to find out a way to execute this script on os x shutdown and giving it a little time to power off completely. However this turned out to be a nightmare: I spent hours looking through several ways to do this with Startup Items, rc.shutdown, cron, launchd, etc... but none of them worked the way I had configured them.

I have to say that I found very limited information on using launchd for a shutdown script execution and I know it's the latest thing in the OS X world so I'm hoping someone out there among you will be able to help me out with this. I still think this is an extremely basic feature to ask for and I was really surprised to find this little documentation on so many different aspects of this problem. Is Fusion too basic of an application for this?

I really hope someone can help. Thank you very much in advance.

share|improve this question
up vote 0 down vote accepted

Have you tried the method discussed in this answer over in stackoverflow ?:-

Basically you start a script at machine start that listens for a SIGTERM and then runs the desired command when it gets it.

share|improve this answer
In the end after having looked around even more I think this is the best solution. I haven't tried it yet but it looks like it pretty much does what I need it to do. Thanks. – Nikksno May 15 '14 at 9:20

Have you install vmware tools? I am able to get my vm guest to shutdown when I shut the computer down myself, however, when the computer shuts off from a UPS battery shutdown command, it doesn't pass it.

share|improve this answer
Yes my guest machine has VMWare Tools installed on it. I can shut it down gracefully using the vmrun command on my host machine however when my host shuts down it will simply terminate the VM [I still have to try Tony's solution]. Would you be able to describe how you configured your setup to achieve this function? As for the UPS shutdown do you have UPS software installed on your guest OS? I noticed the "Pass power status to VM" option in VMWare Fusion global settings: could this have anything to do with it? – Nikksno May 31 '14 at 13:56

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.