APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

set alarm in shell script


What is this stuff?

If this isn't exactly what you wanted, please try our Search (there's a LOT of techy and non-techy stuff here about Linux, Unix, Mac OS X and just computers in general!):



Subject: Re: Is there a way to set an alarm in a shell script?
References: <m04S7.170735$kf1.53509842@news1.rdc1.ne.home.com> 
From: spcecdt@deeptht.armory.com (John DuBois)
Date: 14 Dec 2001 02:34:10 GMT

In article <m04S7.170735$kf1.53509842@news1.rdc1.ne.home.com>,
David H. Funte <jack9x4@hotmail.com> wrote:
>I have a script that uses ftp to transfer files in the middle of the night.
>
>The script hangs on an ftp transfer and sits there (occasionally) forever.
>
>Is there a way to set an "alarm" so that the command only runs for 3000
>seconds and then  exits with an exit code $?.  I'll write this in c if I
>have to , but I'z (I wuz) just wondering if there is a current solution.
>
>For example: timed_run -t 3000 "ftp..."

#!/bin/ksh
ftp... &
pid=$!
(
    (
        sleep 3000&
        echo $!
        wait $! && kill -9 $pid
    )2>/dev/null &
) | read killerPID
wait
kill $killerPID




        John
-- 
John DuBois  spcecdt@armory.com  KC6QKZ/AE  http://www.armory.com/~spcecdt/
 


Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> set alarm in shell script ––>Re: Is there a way to set analarm in a shell script?



Increase ad revenue 50-250% with Ezoic

Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us