Re: Timeout for a script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Ian Blackwell (ian@xxxxxxxxxx) 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
> done
> 
> You may need to vary the signal in the kill statement, depending on what
> you're running.

Hei,

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


Then I found this, which leads me to believe it's not that simple:

    http://www.cit.gu.edu.au/~anthony/info/shell/script.hints

(scroll to "Command timeout")

On that page, they recommend "a simple c solution" timeout.c, which you can
download here: 

ftp.kaist.ac.kr/NetBSD/NetBSD-current/src/lib/libcurses/timeout.c

Anybody bother to comment? How is that thing used? Sorry, I don't speak c.

Regards,
Jussi

--
Jussi Hirvi * Green Spot
Topeliuksenkatu 15 C * 00250 Helsinki * Finland
Tel. & fax +358 9 493 981 * Mobile +358 40 771 2098 (only sms)
jussi.hirvi@xxxxxxxxxxxx * http://www.greenspot.fi

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux