By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,404 Members | 1,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,404 IT Pros & Developers. It's quick & easy.

checking if hour is between two hours

P: n/a
Hi all, i'm again working on my script of parsing logfiles :)
I putted a new function to disable the rule of error between a certain
hours, cause i want to use it as a monitoring script that run every 5
minutes and to disable error in hours of maintenance.
But i have some "problems" to check it.
In the rule-file i have HHMM(start) and HHMM(stop) ----- 0 0 to
disable hours check (i can't check the timestamp in logfile cause not
all the logfiles that i need to check have a timestamp in it).
In the script i wrote:

Actualtime=datetime.datetime.today().strftime("%H% M")
if (start>end):
if (Actualtime>start):
end=int(Hcheck)+1
else:
if (int(Actualtime)<int(end)):
start=Actualtime
if ((int(Actualtime)<int(start)) or (int(Actualtime)>int(end)) or
((start=="0") and (end=="0")) ):
rule=error
...blablabla....
else:
rule=skip
....blablabla....
Why i don't use the complete date with YYMMDDHHMM?
Think about a rule that need to be disabled from hours 20:00 to
04:00.
If i use also yymmdd, in the rule file i need to write a 2000 and
0400+1, the +1 to tell the script that the end
is in the day after, to add a day. But it will work just till the
0000, hour in witch the day will change.

The script work, but is not so "clean"....i just would like some
advice to make it more clean, if possible.

Like always, thanks in advance for the helps :)

May 11 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.