1

I have a script that I've written that needs to run during shutdown which brings down my vagrant instance. The script runs without issue, and I echo output to stdout (and to a file) of the process.

The script outputs the following:

Shutting down vagrant
==> default: Attempting graceful shutdown of VM...
Vagrant shut down

However, when this runs from a computer shutdown (rc0) or reboot (rc6), the terminal logs the first two lines and then moves on without shutting down vagrant.

0

Add a call to the wait command after you halt vagrant. Something like this,

# Shutdown vagrant
vagrant halt
# wait for the halt
wait
  • Thanks Elliot. The issue was actually completely on my end. The rc calls are not asynchronous. I was echoing STDERR to a file. The vagrant halt command threw an exception as it couldn't read the $HOME variable. The exception was written to STDOUT. Removing the redirects, setting a dummy $HOME variable looks like it did the trick. Waiting to gain reputation points to post the answer. – eggmatters Apr 29 '14 at 23:29
  • 1
    @eggmatters When you program any issues are very nearly always completely on your end. – Elliott Frisch Apr 30 '14 at 0:15
  • Yes, that is one of my programming axioms – eggmatters May 22 '14 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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