Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Question about maintenance window and time

Hello All,

So I have an iRULE for schedule maintenance window in our F5. This works great except for some reason is it removing the leading zero from minute, please see the iRULE below:

    when HTTP_REQUEST { 

    # Change the following to set schedule 
    set maintenance_start_time "2204"; 
    set maintenance_end_time "2206"; 
    set maintenance_start_day "Tuesday"; 
    set maintenance_end_day "Tuesday"; 

   #Get time in seconds, formatted as day of week (%A) hour (%k) minute (%M) 
    #Use scan to save output as $cur_day $cur_hour $cur_minute 
    scan [clock format [clock seconds] -format {%A %k %M}] {%s %d %d} cur_day cur_hour cur_minute
    scan [clock format [clock seconds] -format {%s}] {%d} cur_sec
    set cur_time ${cur_hour}${cur_minute} 
    set cur_time_sec ${cur_sec}


     log local0. "\$cur_day: $cur_day, \$cur_hour: $cur_hour, \$cur_minute: $cur_minute, \$cur_time: $cur_time" 
    log local0. "\$cur_time_sec : $cur_time_sec" 


    if { ($cur_time >= $maintenance_start_time) && ($cur_time <= $maintenance_end_time) && ($cur_day >= $maintenance_start_day) && ($cur_day <= $maintenance_end_day) } { 
             if { [HTTP::uri] ends_with "front_image_en.png" }
             <rest of the irule>

So right now I cannot schedule maintenance window say where min is 00 i.e. 1500 or 1400 however when I do 1510 it works as there is no leading zero infront of the 1.

Does anyone know how can I put in the leading zero.

When there is no leading zero this is what I see in the logs

May 19 22:22:45 info tmm3[20399]: Rule /Common/maintenance_window : $cur_day: Tuesday, $cur_hour: 22, $cur_minute: 22, $cur_time: 2222May 19 22:22:45 info tmm3[20399]: Rule /Common/maintenance_window : $cur_time_sec : 1432030965May 19 22:22:45 info tmm3[20399]: Rule /Common/maintenance_window : $cur_day: Tuesday, $cur_hour: 22, $cur_minute: 22, $cur_time: 2222May 19 22:22:45 info tmm3[20399]: Rule /Common/maintenance_window : $cur_time_sec : 1432030965 ##

When there is a leading zero I see the following

May 19 22:06:28 info tmm2[20399]: Rule /Common/maintenance_window : $cur_day: Tuesday, $cur_hour: 22, $cur_minute: 6, $cur_time: 226 May 19 22:06:28 info tmm2[20399]: Rule /Common/maintenance_window : $cur_time_sec : 1432029988 May 19 22:06:28 info tmm2[20399]: Rule /Common/maintenance_window : $cur_day: Tuesday, $cur_hour: 22, $cur_minute: 6, $cur_time: 226 May 19 22:06:28 info tmm2[20399]: Rule /Common/maintenance_window : $cur_time_sec : 1432029988

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Think I have fixed the issue ...

scan [clock format [clock seconds] -format {%A %k %M}] {%s %d %d} cur_day cur_hour cur_minute #

to

scan [clock format [clock seconds] -format {%A %k %M}] {%s %s %s} cur_day cur_hour cur_minute

after reading - https://devcentral.f5.com/questions/time-based-rule

0
Comments on this Answer
Comment made 19-May-2015 by Samir Jha 2944
Can you please correct above irule & paste here. Is it validated?
0