LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash script to stop isdn service after x mintus? (https://www.linuxquestions.org/questions/programming-9/bash-script-to-stop-isdn-service-after-x-mintus-151409/)

paul.nel 02-27-2004 11:19 PM

bash script to stop isdn service after x minutes?
 
I am looking for a script to stop my isdn service or ippp0 interface after x number or minutes. Eg stopthisservice.sh 30. I am struggling to get the basics sorted out like how to measure elapsed time in a bash script etc. I am thinking of a simple script eg:

while timenow < timetoelapse
do
timenow = now + elapseperiod
done

serivce isdn stop

Any ideas where I could look for help

Tx
p.n

crabboy 02-28-2004 12:12 AM

Have the script 'sleep' for 30 minutes.

cjcuk 02-28-2004 03:12 AM

You could also use a two-stage script. Whereby stage one works out the time now plus your input, and calls `at' to perform the second stage of the script at the requested time. The second stage could then actually pull down the connection. Just an idea.

bigearsbilly 03-11-2004 09:57 AM

You don't need to work out the interval,

echo kill_scrip.sh | at now + 30 minutes

see 'man at'

you can keep recursivly calling the script in itself of course.

atq tells you what's on the at queue.

bigearsbilly 03-11-2004 10:01 AM

Or even simpler,

while kill_script.sh; do sleep $(( 30 * 60 )); done &

or better probably...

while sleep $(( 30 * 60 ));do kill_script.sh ; done &



regards,
billy


All times are GMT -5. The time now is 02:34 AM.