Re: [CentOS] Timeout for a script

2008-11-12 Thread Filipe Brandenburger
Hi, On Wed, Nov 12, 2008 at 08:39, Jussi Hirvi [EMAIL PROTECTED] wrote: Thanks - but I couldn't make that work as expected. It seems to kill *something*, but after that, the rsync part still continues in the background... If what you want to kill is the rsync process, do the opposite, run

Re: [CentOS] Timeout for a script

2008-11-12 Thread James Pearson
Jussi Hirvi wrote: Thanks - but I couldn't make that work as expected. It seems to kill *something*, but after that, the rsync part still continues in the background... Here's my last test: log='/root/log/rsync2' timeoutseconds=1 pid=$$ (sleep $timeoutseconds; echo `date '+%c'` $0

Re: [CentOS] Timeout for a script

2008-11-12 Thread William L. Maltby
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,

[CentOS] Timeout for a script

2008-11-12 Thread Jussi Hirvi
How could I make a script time out after nn minutes, if it's not finished by then? The practical context: I have a dozen or so of backup scripts in a directory daily, and they are run by cron like this: 0 23 * * 1-6 run-parts /root/daily Sometimes one of the scripts hang, in which case the rest

Re: [CentOS] Timeout for a script

2008-11-12 Thread Ian Blackwell
Jussi Hirvi wrote: How could I make a script time out after nn minutes, if it's not finished by then? I put this little test script together. It seems to work OK... #!/bin/bash timeoutseconds=5 pid=$$ (echo Will kill $pid in $timeoutseconds seconds; sleep $timeoutseconds; kill -1 $pid)

Re: [CentOS] Timeout for a script

2008-11-12 Thread Jussi Hirvi
Ian Blackwell ([EMAIL PROTECTED]) kirjoitteli (12.11.2008 12:13): I put this little test script together. It seems to work OK... #!/bin/bash timeoutseconds=5 pid=$$ (echo Will kill $pid in $timeoutseconds seconds; sleep $timeoutseconds; kill -1 $pid) while true do echo Hello sleep 0.6

Re: [CentOS] Timeout for a script

2008-11-12 Thread William L. Maltby
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? The practical context: I have a dozen or so of backup scripts in a directory daily, and they are run by cron like this: 0 23 * * 1-6 run-parts

Re: [CentOS] Timeout for a script

2008-11-12 Thread Amos Shapira
Or maybe the next script that cron executes can kill the previous one as a first step before doing anything else. --Amos On 11/13/08, Filipe Brandenburger [EMAIL PROTECTED] wrote: Hi, On Wed, Nov 12, 2008 at 08:39, Jussi Hirvi [EMAIL PROTECTED] wrote: Thanks - but I couldn't make that work