Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
TERM can be caught and handled. –  Dennis Williamson Feb 19 '11 at 19:09
    
Yes, but then it does SIGKILL a second later; I'll update my post. –  Steven Feb 19 '11 at 22:03

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
share|improve this answer

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.