[8634 views]

[]

[toggle ads]

Timeout kill

In Linux there is no standard way to deal with runaway processes. A runaway process I call a program that appears to "hang" and needs to be killed to terminate. Effects like that are a reality. And we shouldn't ignore them. They are very annoying when they occur in automated processes. Such as cron jobs. We need a way to set an upper time limit to a processes runtime. This is actually something very familiar to a real-time system. But not to Linux today. timeout is a small shell script that does just that: send a signal to a process after some time if it hasn't died yet and wait for it to die. The following would for instance terminate mplayer playing a video stream after five minutes:

timeout -TERM 5m mplayer tv://

If you have suggestions for improvement (in the form of a patch), please feel free to contact me.

Download

timeout and a few simple test cases: test-timeout