Now I enhanced the script little bit for more logging.
echo `date` executing $0 $* >> /home/janakiramans/vm-suspend.log
for vm in `VBoxManage list runningvms | cut -d " " -f 2`; do echo saving $vm >> /home/janakiramans/vm-suspend.log; VBoxManage controlvm $vm savestate;echo saved $vm >> /home/janakiramans/vm-suspend.log; done
echo `date` executed $0 $* >> /home/janakiramans/vm-suspend.log
Additional background info...
This script gets the list of running virtual box virtual machines and saves the current state (similar to hibernate).
Without this script, if the laptop hits hibernate because of critical battery, the machine hangs (looks like it) because of running virtual box.
With this script, the running virtual boxes will be saved when the laptop hits low battery and will hibernate the host os (PCLOS here) at critical battery.