Kron: poor-man's cron

When two groups within Cisco needed time-based command execution in Cisco IOS, they (in a typical big-corporation fashion) decided to implement the same wheel from two different sets of spokes and rims. One group built the Embedded Event Manager with its event timer cron command (introduced in 12.2(25)S and 12.3(14)T), the other group created the more limited kron command set (introduced in 12.3(1)).

EEM is almost a perfect superset of kron, both can trigger a set of CLI commands at reload, at periodic intervals or at certain time in the future. The only extra functionality offered by kron is the ability to specify a different username for each event (whereas all EEM applets have to run under a common username) … and kron is available in older IOS releases.

Similar to EEM applets, CLI commands executed within kron cannot expect extra input (so you cannot execute clear counters or reload from kron) and the output they generate is lost unless you use output filters to redirect it to an external file.

Here is a simple configuration that archives the router's running configuration every sunday half an hour before midnight:

kron policy-list archiveConfig
 cli archive config
!
kron occurrence archiveConfig at 23:30 Sun recurring
 policy-list archiveConfig

5 comments:

  1. If I put a tcl script to run from EEM applet and use typeahead to put my answer to the interactive command will my script be running?

    ReplyDelete
  2. This is tricky. If you use EEM Tcl policy, the answer is probably "yes" (although I haven't tested the cli_* routines yet), if you use earlies IOS releases, the answer is "maybe" (typeahead didn't work properly in some of them), if you use 12.4(15)T, the answer is "I don't know" as the rules controlling where you can run Tcl scripts have changed (for example, you cannot run them through web server anymore).

    It looks like some tests will have to be done :)

    ReplyDelete
  3. May something other break things like the example below in 12.4(15)T ?

    event manager applet midnight
    event timer cron name midnight cron-entry "@midnight"
    action 1.0 cli command "enable"
    action 2.0 cli command "tclsh flash:midnight.tcl"

    ReplyDelete
  4. I believe the the kron command was ported over to IOS from the MDS SanOS platform.

    ReplyDelete
  5. Relaod with Kron works ;)

    ReplyDelete

You don't have to log in to post a comment, but please do provide your real name/URL. Anonymous comments might get deleted.

Ivan Pepelnjak, CCIE#1354, is the chief technology advisor for NIL Data Communications. He has been designing and implementing large-scale data communications networks as well as teaching and writing books about advanced technologies since 1990. See his full profile, contact him or follow @ioshints on Twitter.