Grokbase
Topics Posts Groups | in
x
[ help ]

Re: Timeout for a script

View PostFlat  Thread  Threaded | < Prev
William L. Maltby Re: [CentOS] Timeout for a script
| +1 vote
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
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

_______________________________________________
CentOS mailing list
[email protected: C...@centos.org]
http://lists.centos.org/mailman/listinfo/centos

Thread : Timeout for a script
1)
Jussi Hirvi How could I make a script time out after nn minutes, if it's not finished by then? The practical...
2)
Ian Blackwell I put this little test script together. It seems to work OK... #!/bin/bash timeoutseconds=5 pid=$$...
3)
Jussi Hirvi Ian Blackwell (ian@ikel.id.au) kirjoitteli (12.11.2008 12:13): Hei, Thanks - but I couldn't make...
4)
Filipe Brandenburger Hi, If what you want to kill is the rsync process, do the opposite, run rsync in background, sleep...
5)
Amos Shapira Or maybe the next script that cron executes can kill the previous one as a first step before doing...
6)
James Pearson Try replacing the 'kill -9 $pid' with '/usr/bin/kill -s KILL -$pid' I've used something based on:...
7)
William L. Maltby Do "man bash" and search for "trap". For those not familiar, it can be a little confusing, but it's...
8)
William L. Maltby <*sigh*> Well, it seems that bash doesn't have some of the stuff ISTR from the original *IX stuff...
spacer
View PostFlat  Thread  Threaded | < Prev
Home > Groups > CentOS > Timeout for a script (8 posts) > View Post