I have the following script, how do I run it on shutdown in debian linux? (don't want to use GUI)
#!/bin/bash
vms=$(vmrun list | grep '/');
for vm in ${vms}
do
echo 'suspending ' $vm
vmrun suspend $vm soft
done
I tried adding it to /usr/local/bin with chmod +x permissions. Then I created symbolic links to rc0.d (shutdown) and rc6.d (reboot).
I then did update-rc.d shutdown_vms 0 6 .
When I do shutdown -r now, it switches to console mode to restart....at that point I can see a error message stating shutdown_vms has failed.
I this the proper way to install the shutdown script and why is it failing (where do I look in the logs?)
Edit: I used the command update-rc.d -f shutdown_vms start 0 0 6 .
When I look at the start up list for rc0.d (shutdown), i see that both shutdown_vms, vmware, and gdm are all order of 0. I think if gdm fires before shutdown_vms, it will kill the vms. I think this is what's happening because when I log the number of vms running when the script executes, it logs 0.
Can I change the order of gdm/vmware to 1 so that shutdown_vms run first?