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

set alarm in shell script


© December 2004 (various authors)

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  https://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?


Inexpensive and informative Apple related e-books:

Take Control of Apple Mail, Third Edition

Take Control of Pages

Take Control of Parallels Desktop 12

Photos for Mac: A Take Control Crash Course

El Capitan: A Take Control Crash Course





Printer Friendly Version

Have you tried Searching this site?

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


Printer Friendly Version





Yeah, it's obsolete, clunky, insecure and broken, but people still use this stuff (Tony Lawrence)




Linux posts

Troubleshooting posts


This post tagged:

SCO_OSR5



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode





SCO Unix Sales, Support, & Service

Phone:  707-SCO-UNIX (707-726-8649Toll Free: 833-SCO-UNIX (833-726-8649)
www.SCOsales.com