This script would be using two commands available on the esxi.

    /sbin/powerOffVms (Stop the current’s running vms)
    /bin/poweroff (Stop the Esx host)

I have called it: auto-shutdown.sh
 ----------
 Details:
 #! /bin/ash
 echo "shutting down VMs..please wait.."
 /sbin/powerOffVms
 echo "done."
 echo "shutting down the host now.."
 /bin/poweroff


———-

Apply the execution’s rights :

chmod +x /vmfs/volumes/datastore1/auto-shutdown.sh

Add this script in /etc/rc.local

/bin/echo “0 22 * * * /vmfs/volumes/datastore1/auto-shutdown.sh” >> /var/spool/cron/crontabs/root

This script would stop the vms and the Esxi host everyday at 22h.









本文转自 h2appy  51CTO博客,原文链接:http://blog.51cto.com/h2appy/1106164,如需转载请自行联系原作者
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐