Forum Discussion

Gordon_Johnston's avatar
Gordon_Johnston
Icon for Nimbostratus rankNimbostratus
Oct 16, 2005

Date/Time sensitive iRules

Another question if I may.

 

 

How can I query the current time of day with an iRule. I'd like an iRule to apply at only certain times of the day, and rather than writing cron entries to update the config (ugly) I'd like to do this with the iRule itself. Is this possible? Can you point me in the way of some documentation, I couldn't find anything relevent.

 

 

Cheers
  • Have you considered writing iControl external scripts to make these config changes... You'd still need a scheduler to trigger the scripts, but at least you'd be using their API.

     

     

    -Brian
  • use the clock command: http://tmml.sourceforge.net/doc/tcl/clock.html

    
          set curtime [clock seconds]
          set formattedtime [clock format $curtime]
          log "$curtime seconds since epoch, $formattedtime"

    The log entry looks like this:

    1129552706 seconds since epoch, Mon Oct 17 07:38:26 CDT 2005

    .
  • If you only want to return hours and minutes for easier evaluation, change the format line to read:

    
          set formattedtime [clock format $curtime -format {%H:%S} ]

  • set formated_time [clock format $time_now -format {%Y-%m-%d %H:%M:%S}]

    You can use this format.

    Thanks.