4

I want to run script on server shutdown. It's a KVM host and I want to shutdown my VMs. How much time will system wait for my script to exit? Indefinitely?

2 Answers 2

2

You have as much time as you want as it depends on how you're shutting it down and how you run your script.

You could setup your shutdown process to block on your script, then you have as much time as your want. It won't continue shutting down until your script exits.

Then there is setup's like Knoppix which send a TERM then a KILL to all processes pretty quickly during shutdown. So you'd have almost no time for your script.

2
  • TERM can be caught and handled. Feb 19, 2011 at 19:09
  • Yes, but then it does SIGKILL a second later; I'll update my post.
    – Steven
    Feb 19, 2011 at 22:03
2

Depends on the version init programs. For sysvinit(System V style init programs) and upstart(riginally developed for the Ubuntu distribution) no time limit. Sometimes use killall5 to shutdown(shutdown script don't run).

Also, you can set kill timeout(time to wait between sending TERM and KILL signals) in upstart(in /etc/init):

kill timeout 180

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .