Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-01-2012, 08:20 AM   #1
LQ Newbie
Registered: Dec 2011
Posts: 9

Rep: Reputation: Disabled
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:
#! /bin/sh
vms=$(vmrun list | grep '/');
echo $(date) >> /home/log
echo 'total vms:'  ${vms}  >> /home/log
for vm in ${vms}
        echo 'suspending vm ' $vm >> /home/log
        vmrun suspend $vm soft
        echo 'done, sleeping 10 seconds' >> /home/log
        sleep 10
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?
Old 01-02-2012, 07:54 AM   #2
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 103Reputation: 103

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.

Hope this helps.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fighting with making running a script at startup only but not at shutdown/reboot ... Xeratul Debian 5 12-01-2010 01:13 PM
Script to close running apps before shutdown. Unknown_Entity Linux - Desktop 4 08-16-2009 05:41 PM
Shutdown script for Crunchbang Linux running from USB on Asus Surf 2G Maestro01 Linux - Laptop and Netbook 5 03-19-2009 11:11 AM
Script i created isn't running on Shutdown WHY aaarrghh?? helptonewbie Linux - General 18 01-07-2008 04:46 PM
Automatically running script at shutdown samac Slackware 2 05-14-2005 10:10 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:23 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration