Scheduling of Router Commands:
You want to issue a command for the router to execute at regularly scheduled times.
Use the router’s Kron facility to execute commands at regularly scheduled intervals:
Cisco first introduced the Kron facility in IOS Version 12.3(1).
The Cisco Kron facility is similar to the Unix Cron facility in that it allows you to schedule commands to be executed at regular intervals. In essence, it allows you to automate certain administrative functions that the router administrator would otherwise have to perform manually. Of course the major advantage is that once configured correctly, the Kron facility issues the commands at the exact time required and without the chance of typos. In addition, it does not require the administrator be present when the commands are run, which is important, especially in organizations with large numbers of routers.
Let’s take a closer look at the configuration of the Kron facility. In the example provided, we have configured the Kron facility to automatically save the configuration to NVRAM each day at 17:00 (5:00PM). First, we configured the kron policy-list and named it “OREILLY” and included the single CLI command “write memory.” We then configured the kron occurrence named “DAILYat5” and set the launch time to 17:00. The keyword recurring is required to ensure that the Kron occurrence launches each day as opposed to a single instance. Once the Kron occurrence was configured, then we defined which Kron policies where to be invoked. Note that you can launch more than one Kron policy per occurrence, as shown in the next example:
In this example, we have configured two Kron policies to launch via the same Kron occurrence. This means that each day at 17:00 the router will launch both policies.
As with the Unix Cron facility, you can schedule Kron occurrences to run every minute of the hour, once a year, or anywhere in between. To schedule a Kron occurrence to launch every hour, use the in keyword in conjunction with the recurring keyword:
The Kron facility will now launch the Kron occurrence “Hourly” every 60 minutes. To launch a Kron facility once a year, use the following configuration:
Unfortunately, there are some rather annoying limitations to the Kron facility. First of all, only EXEC level commands can be issued by the Kron facility, meaning that no configuration-based commands can be issued. Second, the Kron facility won’t work with interactive-based EXEC commands, meaning commands that prompt you to verify the command. For instance, in the initial example we issued the CLI command write memory instead of copy running-config startup-config because the write command does not prompt to verify the action whereas the copy command does.
Some potentially useful uses for the Kron facility are saving the configuration to NVRAM, disabling all debug commands, clearing a particular interface, issuing a ping command to keep up a tunnel, etc.
You can view the scheduled Kron occurrences by using the show kron schedule command:
You can see that the router will launch the Kron occurrence “DAILYat5” in 5 hours and 40 minutes.