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

TESTING VARIABLE FOR A NUMBER OF VALUES

Status
Not open for further replies.

hubud

Instructor
Oct 18, 2002
123
GB
I am using the following test to establish at what time of day a command has run.

time=`date '+%H'`

if [ $time = "13" ]
then
at 01:00 tomorrow < leads.ksh
fi

if [ $time = &quot;01&quot; ]
then
at 13:00 today < leads.ksh
fi

There is a little problem in that some of the other processing can cause the scripts to run at times other than at 1300 and 0100 hours.

What I'm after is how to test that the $time variable is running in the morning 0100-1100 and evening 1200-2300.

I felt that using the hour part of date would be best though there maybe a better way?

Any help would be appreciated


cheers

simmo
 
You can test for a range of values like this:
[tt]
if [[ $time -ge 13 && $time -le 23 ]]
then
echo hour is within the range 13..23
else
echo otherwise
fi
 
Might i suggest using cron,
with the following crontab entry:

0 1,13 * * * ${DIR}/leads.ksh

this would ensure that leads is invoked at 1am and 1pm.

---------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top