cancel
Showing results for 
Search instead for 
Did you mean: 

Scheduling of an iRules for specific time

Hien_Truong
Cirrus
Cirrus

i need help to schedule the irules (2 irules) for specific time.

 

1) Run the below irule on Monday from 5:00 am to 1:30 am Tuesday then stop this irule:

 

 when HTTP_REQUEST { 

  if { ([string tolower [HTTP::host]] eq "abc.com") and ([string tolower [HTTP::uri]] eq "/hello") } {

    HTTP::redirect "https://abc.com/web/PRAu/"

  }

}

 

 2) Run the below irule on Tuesday from 10:30 am to 3:00 am Wednesday then stop this irule and run this irule again on Wednesday from 9:00 am to 10:00 am then stop.

 

when HTTP_REQUEST {

 if { [string tolower [HTTP::host]] eq "abc.com"} {

  HTTP::respond 302 Location "https://abc.com/fastservice-dashboard"} 

}

 

Thanks for your help.

1 REPLY 1

crodriguez
F5 Employee
F5 Employee

iRules are connection based, meaning they are triggered in response to a connection, not at a scheduled time. Having said that, you could have the iRules configured on the BIG-IP system but not assigned to the virtual server. Then you can use an automated script that runs at the start of a time period to assign the iRule to the virtual server, and runs again at the end of the time period to remove the iRule from the virtual server. (iControl REST API is perfect for this.)

 

The only way I can think of to actually control the timing from within the iRule is for it to check the current time (clock) at every HTTP_REQUEST event, then exit the iRule (return) if the current time is not within the desired window. That seems like a lot of unnecessary overhead though since, more often than not, the event is triggered at a point that is not within one of those scheduled time periods, but still has to go through the motions of checking the time.

 

As an aside, you can do what your iRules do with a local traffic policy, which is more efficient. Your automated script can assign and remove the policy as easily as it can the iRule.