LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-27-2004, 11:19 PM   #1
paul.nel
Member
 
Registered: Nov 2003
Location: Cape Town
Distribution: Gentoo, Redhat 9, SuSE 9.0, 9.2, Win XP
Posts: 149

Rep: Reputation: 15
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

Last edited by paul.nel; 02-27-2004 at 11:49 PM.
 
Old 02-28-2004, 12:12 AM   #2
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
Have the script 'sleep' for 30 minutes.
 
Old 02-28-2004, 03:12 AM   #3
cjcuk
Member
 
Registered: Dec 2003
Distribution: Openwall, ~LFS
Posts: 128

Rep: Reputation: 15
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.
 
Old 03-11-2004, 09:57 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,287

Rep: Reputation: 173Reputation: 173
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.
 
Old 03-11-2004, 10:01 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,287

Rep: Reputation: 173Reputation: 173
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i cleanly stop a service? n0vembr Linux - General 18 07-29-2005 04:11 AM
Bash script to alert by email 3 times then stop. pmpc00 Linux - General 2 11-04-2004 07:23 AM
service won't stop in RH9 hairydan Red Hat 6 04-09-2004 01:05 PM
Starting a service in a bash script AMMullan Programming 3 02-19-2004 11:06 AM
Mandrake - how to stop a service? taz76 Linux - Security 1 03-13-2003 06:31 AM


All times are GMT -5. The time now is 05:29 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration