Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am currently learning upstart by playing around. I think I have understood the principle now, but I am having difficulties with the "kill timeout" stanza in upstart jobs.

For example, I have the following job (filename /etc/init/test.conf):

description "test"
start on test
console owner
kill timeout 5
task
exec /root/test

The file /root/test is a small shell script which runs forever:

while true; do o=1; done;

When doing "initctl start test", the job "test" is run and calls the script "/root/test". I can verify that by doing "initctl status test" which shows the job as running as well as by doing "ps -Alf".

Now, the "kill timeout 5" stanza should cause the job to be killed after 5 seconds. But instead, the job seems to run forever.

I would like to know if I am using and understanding the kill timeout stanza in the right way. It is an essential feature for me.

This is on Natty 11.04, but I think the question applies to other versions as well.

Thank you very much,

Binarus

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

That's not what kill timeout does; it specifies how long to wait after sending a polite "terminate" signal for the process to exit before giving up and launching nukes.

If you want to set a process time limit in the upstart way, the easiest way is probably to have something periodically issue a timer event, and use stop on timer. Alternately (and perhaps more generally), create a wrapper program which forks a small process which sends an event after a time period, and stop on that event.

For more information and best practices, see The Upstart Cookbook.

share|improve this answer
    
Thank you very much! Then I'll just make sure that none of my "custom" upstart jobs will run forever. –  Binarus Mar 14 '11 at 19:10
add comment

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.