[CentOS] Timeout for a script
William L. Maltby
CentOS4Bill at triad.rr.com
Wed Nov 12 11:26:01 UTC 2008
On Wed, 2008-11-12 at 05:37 -0500, William L. Maltby wrote:
> On Wed, 2008-11-12 at 11:54 +0200, Jussi Hirvi wrote:
> > How could I make a script time out after nn minutes, if it's not finished by
> > then?
> ><snip>
> Do "man bash" and search for "trap". For those not familiar, it can be a
> little confusing, but it's well worth the effort, in terms of results
> and learning.
<*sigh*>
Well, it seems that bash doesn't have some of the stuff ISTR from the
original *IX stuff (builtin alarm? not sure anymore). Anyway, a google
for "bash alarm trap" led to this and there are lots more. This was just
the first and may not be the best for your needs.
http://steve-parker.org/sh/trap.shtml
Anyway, sans "alarm", a trap, sleep, SIGUSR* or SIGINT combination should
do nicely.
HTH
--
Bill
More information about the CentOS
mailing list