[CentOS] Timeout for a script

James Pearson james-p at moving-picture.com
Wed Nov 12 14:26:45 UTC 2008

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 INTERRUPTED" >>$log;
>     kill -9 $pid) &
> /usr/bin/rsync -avzu --delete /root /home/palvelimet/bckserver1
> echo `date '+%c'` " $0 valmis" >>$log

Try replacing the 'kill -9 $pid' with '/usr/bin/kill -s KILL -$pid'

I've used something based on:


which seems to work fine

James Pearson

More information about the CentOS mailing list