Forum Discussion
Andre_Muniz
Jul 01, 2011Nimbostratus
Schedule iRule
Im new in iRule. Im using a iRule and its ok, but i need to schedule this. I need that iRule to be enabled only a certain part of the day. How can I do that ? Thanks
Michael_Yates
Oct 12, 2012Nimbostratus
Hi Steve,
If you do not want to set the flag you can move the event from CLIENT_ACCEPTED to HTTP_REQUEST (First Example), but if you do want to use a variable you could use the Second Example).
The first example is more efficient (sorry...should have just told you to change the event, but I thought I would show you both).
I would suggest the first example.
when RULE_INIT {
Start of maintenance window in YYYY-mm-dd HH:MM format
set static::start_date "2012-10-12 17:20"
End of maintenance window in YYYY-mm-dd HH:MM format
set static::end_date "2012-10-12 17:22"
Convert start/end times to seconds from the epoch for easier date comparisons
set static::start [clock scan $static::start_date]
set static::end [clock scan $static::end_date]
}
when HTTP_REQUEST {
set now [clock seconds]
if { $now > $static::start and $now < $static::end } {
HTTP::redirect "http://www.google.com"
}
}
------------------------------------------------------------------------------------------------------------
when RULE_INIT {
Start of maintenance window in YYYY-mm-dd HH:MM format
set static::start_date "2012-10-12 17:30"
End of maintenance window in YYYY-mm-dd HH:MM format
set static::end_date "2012-10-12 17:32"
Convert start/end times to seconds from the epoch for easier date comparisons
set static::start [clock scan $static::start_date]
set static::end [clock scan $static::end_date]
}
when CLIENT_ACCEPTED {
set now [clock seconds]
if { $now > $static::start and $now < $static::end } {
set maintflag "1"
}
else {
set maintflag "0"
}
}
when HTTP_REQUEST {
if { $maintflag == 1 } {
HTTP::redirect "http://www.google.com"
}
}
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects