Take the 2-minute tour ×

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
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,


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


