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.email@example.com> From: firstname.lastname@example.org (John DuBois) Date: 14 Dec 2001 02:34:10 GMT In article <m04S7.email@example.com>, David H. Funte <firstname.lastname@example.org> 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 email@example.com KC6QKZ/AE https://www.armory.com/~spcecdt/
Got something to add? Send me email.