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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeat job every "m" mins for "h" hrs starting at "t&qu 1

Status
Not open for further replies.

blodwyn

IS-IT--Management
Mar 23, 2001
24
0
0
Hi

I've always had a very helpful response from you experts out there and I hope that somebody will assist me now.

I'm trying to write a script that will kick off a monitoring job script at a prompted time, to repeat every so many prompted minutes, until a certain time, or for a prompted number of hours.

Because the parameters can vary,and the job is an ad hoc one, I don't want to use the crontab facility. I'm looking at "at", "repeat" and "sleep' but am having trouble loading all the variables into the script. I'm also sure there must be a less messy way.

Thanks in advance

Blodwyn
 
Post the script you have so far and explain where you are in trouble with.
 
Some ideas that might help...

#!/usr/bin/ksh

read START?'Start time (HH:MM) ? '
read REPEAT?'How often to repeat (minutes) ? '
read END?'End time (HH:MM) OR how long to run (hours) ? '

at $START <<!!
while [ -f flagfile ]
do
run_your_script_here
sleep $((REPEAT * 60))
done
!!

if [[ $END = *:* ]]
then
if [[ $END > $START ]]
then
echo &quot;rm flagfile&quot; | at $END
else
echo &quot;rm flagfile&quot; | at $END tommorrow
fi
else
echo &quot;rm flagfile&quot; | at $START + $END hours
fi

 
Thanks Ygor, that looks great - some of the syntax is new to me, which is good.

Where does flagfile come from?

Regards

Blodwyn
 
I missed that bit out. You will need to put in some validation checks on user input and if all OK then touch flagfile else exit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top