Computing.Net > Forums > Unix > Timer in a shell script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Timer in a shell script

Reply to Message Icon

Name: Peter
Date: October 25, 2002 at 18:05:45 Pacific
OS: Redhat 7.3
CPU/Ram: pent 100 - 128meg
Comment:

I'm trying to write a shell script that acts as a watchdog timer. Basically it needs to look for a file being created by another process and if it finds it, it starts its timing cycle over. If it times out before seeing that file, it will run another script.

I know I can assign a variable X=`date +%S` as a starting point and I know how to check for the file, but I just can't seem to put it all together so it works.

Help?



Sponsored Link
Ads by Google

Response Number 1
Name: Rex Lopez
Date: October 28, 2002 at 17:29:50 Pacific
Reply:

This is pigeon code on how u might layout script.
It wakes up every second incrementing the timer and checking it against the timeout value. If the file is present, then the timer is reset.
If ur using the old bourne shell (/bin/sh) u'll have to use expr for the maths.

TimeOut=30
Timer=0
while true
do
sleep 1
Timer=Timer+1
if FileExists then Timer=0
else
if Timer = TimeOut then RunNewProg

fi
done


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Timer in a shell script

Auto say y or n in a shell script www.computing.net/answers/unix/auto-say-y-or-n-in-a-shell-script/4059.html

Exit from sqlplus in a shell script www.computing.net/answers/unix/exit-from-sqlplus-in-a-shell-script/8244.html

Parameter file for a shell script www.computing.net/answers/unix/parameter-file-for-a-shell-script/6026.html