Forum Discussion
Chad_Roberts_21
Nimbostratus
May 16, 2006Time-based iRules
I hope this question is unique enough to be worthy of a new post. Unfortunately, searching for the word "time" with various other keywords didn't appear to be specific enough to find my anything of in...
Chad_Roberts_21
Nimbostratus
May 16, 2006Nevermind my last request. Given enough time and caffeine, anything is possible. In case anyone in the future would like to accomplish a similar task, here is the code I used:
when HTTP_REQUEST {
set current_day [clock format [clock seconds] -format {%a} ]
set current_time [clock seconds]
set time_min [clock scan {08:00}]
set time_max [clock scan {17:00}]
if {($current_day == {Sat}) or ($current_day == {Sun})} {
pool after_hours_pool
}
elseif {($current_time < $time_min) or ($current_time > $time_max)} {
pool after_hours_pool
}
}
Note that my goal was to send traffic to an after-hours server on weekends, before 8 AM, and after 5 PM. Because I did not specify an "else", traffic that does not match these requests passes through the iRule unaffected and is acted upon as though the iRule does not exist at all.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
