Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run script 3 times and then stop it.

Status
Not open for further replies.

ojosVerdes

Technical User
Oct 10, 2002
50
US
I have a script that I want to run 3 times (every 20 minutes) then stop it.

I understand how the sleep command works; but I am not sure what looping contruct to use.

I dont want to use a crontab job cause don't have specific times to run it.

TIA.
 
how about running it 3 times without any loop constructs at all:

script
sleep 20
script
sleep 20
script
Ed Fair
unixstuff@juno.com
Any advice I give is my best judgement based on my interpretation of the facts you supply. Help increase my knowledge by providing some feedback, good or bad, on any advice I have given.
 
got u.
How would you run it then if the sleep 1200 is inside the scrip?

OVerdes.
 
I probably would try copying the script 3 times to a new file, then editing the new file to add the sleep 20s, and would pull the sleep 1200 at the same time. Ed Fair
unixstuff@juno.com
Any advice I give is my best judgement based on my interpretation of the facts you supply. Help increase my knowledge by providing some feedback, good or bad, on any advice I have given.
 
If your running a Redhat Linux box you can put it in the crontab and use "*/20" where you would put the time. */20 says "run every 20 minutes." Meekness: Uncommon patience in planning a revenge that is worth while.
-- Ambrose Bierce
 
alternative: cut thin ia file called what-ever-ypu-want.sh
-------------

/bin/sh
case ${SLEEP:=$1} in [1-9]*[0-9]);; *) SLEEP=1;; esac

## a, b and c are dummy flags to repeat 3 times the job
## you also could define a counter !!

for x in a b c
do
copy your scripts here
sleep $SLEEP
done
-------------
give run permissions and
call your shell with(out) a params vox clamantis in deserto.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top