Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 an 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?)

share|improve this question
    
Does the script work correctly if you do sudo /etc/rc0.d/shutdown_vms stop ? Also, can you add an exit 0 to the end of the script. –  Paul Dec 30 '11 at 22:33

1 Answer 1

up vote 1 down vote accepted

Please place your script into /etc/init.d/ and chmod +x it. Then execute following command:

    update-rc.d yourscript start 0 6 .

How it looks after command execution:

    ll /etc/rc0.d/*yoursc*
    lrwxrwxrwx 1 root root 20 Jun 23 21:09 /etc/rc0.d/K01yourscript -> ../init.d/yourscript
    ll /etc/rc6.d/*yoursc*
    lrwxrwxrwx 1 root root 20 Jun 23 21:09 /etc/rc6.d/K01yourscript -> ../init.d/yourscript
share|improve this answer
    
can you update your answer with info using the symlink the OP is interested in ? –  Jeremy W Jun 23 '12 at 1:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.