Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I wrote a script that suspend all my virtualbox machines, and put a line in /etc/rc.local.shutdown, but it doesn't seem to work,

su - XX -c /XX

When I'm booted next time, virtualbox tells me the machine was Aborted, so the script wasn't executed. (Launching that script manually works for me)

P.S I already enabled shutdown.target

EDIT

The problem seems complicated than I thought, in my bashrc, if it's running on tty3, it executes startx, so when systemd decide to shutdown/reboot, it whould kill VBoxSVC process and other stuff when X session dies.

I also tried to hack the source code of xfsm-shutdown-helper, make a fake systemctl that execute my script first, none of the above works.

share|improve this question
Out of curiosity, how many VMs are you shutting down in tandem? .. Unrelated to your question, but I believe I've found an issue in VirtualBox 4.2.6 where shutting down too many at once (5 to 10) (all are linked-clones from a shared VM) leads to corrupted cloned VMs. – adamrmcd Dec 31 '12 at 5:43
@adamrmcd I'm shutting down one-by-one... – warl0ck Dec 31 '12 at 6:12
Do you want to suspend the VMs rather than shutting them down? In a classic (SysV?) init-based system, you should be able to do that from inittab / by modifying the scripts for the runlevel used for shutdown... (read the init man page, it differs between unixes, possibly between Linux distributions as well) – Gert van den Berg Dec 31 '12 at 6:16
You might also want to echo something to a logfile from the script, to be sure that it actually didn't run, rather than just failed as a result of something else... – Gert van den Berg Dec 31 '12 at 6:20
1  
If ti supports SysV style init scripts, you would add a script like /etc/init.d/stopvms that stop the VMs when passed a "stop" parameter. You then create links (symbolic or hard) to that script as say /etc/rc5.d/K01stopvms and /etc/rc3.s/K01stopvms . (the scripts in the directories are run in order (K* when leaving a runlevel, S* when entering a runlevel)) (You should also be able to do it as "start" scripts in runlevels 0 (shutdowns) and 6 (reboots)) – Gert van den Berg Dec 31 '12 at 6:46
show 4 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.