LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Shutdown script not running (https://www.linuxquestions.org/questions/linux-newbie-8/shutdown-script-not-running-921482/)

firebirdsql 01-01-2012 08:20 AM

Shutdown script not running
 
I have a shutdown script that suspends all vmware workstation guests when the host is shutdown.

I manually placed symbolic links to the shutdown script in rc0.d (shutdown) and rc6.d (reboot). (ln -s /etc/init.d/shutdownvms /etc/rc0.d/K00shutdownvms)

The /etc/init.d/shutdownvms script is:
Code:

#! /bin/sh
vms=$(vmrun list | grep '/');
echo $(date) >> /home/log
echo 'total vms:'  ${vms}  >> /home/log
for vm in ${vms}
do
        echo 'suspending vm ' $vm >> /home/log
        vmrun suspend $vm soft
        echo 'done, sleeping 10 seconds' >> /home/log
        sleep 10
done
exit 0


The problem is, my script runs but it shows that there are 0 vms running.

In my rc0.d, I see that there is K01gdm which kills xserver/gdm. I think if those are killed, the VMware guests are also killed. However my script should be firing before that because it has a order of 0.

Maybe when gnome shutdown is trigger, it kills xserver etc.

How do I resolve this?

jv2112 01-02-2012 07:54 AM

The scripts are run by naming conventions . K01 before K02 and so on. So you need to ensure your script runs prior to the script that kills the users.


http://www.yolinux.com/TUTORIALS/Lin...itProcess.html

Hope this helps.


All times are GMT -5. The time now is 12:33 PM.