Want to learn more about router and
switch management? Automatically
sign up for our free Cisco Routers and Switches newsletter, delivered each
has a built-in command scheduler called kron.
Introduced in Cisco IOS 12.3(1), this command scheduler is similar to the
Windows at program and the UNIX cron or at programs.
allow you to run commands, or a sequence of commands, once or on a recurring
calendar. Let’s look at how you use a command scheduler on a Cisco router.
Use the command scheduler
example, let’s say you want to automatically back up your router’s running configuration
(in RAM) to the startup configuration (in NVRAM) every Monday night at 10 P.M.
You might want to make sure that the system is preserving router changes, even
if the router losses power–and even if someone forgets to save his or her changes.
IOS command scheduler makes this a relatively easy task. Here’s how you can use
kron to accomplish this.
create a kron policy list. Essentially,
this policy list serves as your “script,” which lists what you want
the router to run at a scheduled time. Here’s an example:
Router(config)# kron policy-list backup Router(config-kron-policy)# cli write Router(config-kron-policy)# exit
create a kron occurrence, in which
you tell the router when and how often you want to run this policy list (i.e., group
of commands). Here’s an example:
Router(config)# kron occurrence backup at 22:00 Mon recurring Router(config-kron-occurrence)# policy-list backup
sets up your backup job to run every Monday night at 10 P.M. (22:00 in military
verify that you’ve entered everything correctly by using the show command.
Router# show kron schedule
Kron Occurrence Schedule backup inactive, will run again in 2 days 22:03:46 at 22:00 on Mon
Router# show running-configuration (truncated) kron occurrence backup at 22:00 Mon recurring
policy-list backup ! kron policy-list backup
cli write (truncated)
be wondering why I used the write
command instead of the copy
running-configuration startup-configuration commands. While the copy run start command is interactive,
the write command is not. In other
words, write doesn’t prompt to verify
what you want to do. It’s important to remember that the Cisco IOS Command
Scheduler doesn’t allow any interactive commands.
Know your limitations
thing to look out for is that kron has
more limitations than its Windows or UNIX counterparts. For example, you can
only use privileged-mode commands with kron;
it doesn’t allow any Global or Interface configuration commands. This is
because it executes each command separately.
addition, it doesn’t allow you to edit the list of commands once you’ve entered
them. Therefore, you should test the command sequence before entering it. If a
command in the sequence fails, the router will delete that sequence of commands
and not run it again.
these limitations may be due to the fact that the command scheduler’s primary
design appears to be to allow Cisco routers to contact Cisco’s CNS server to
request an automatic upgrade. While this is a good use for the command
scheduler, you can also use it for a number of other handy tasks.
Learn additional uses
be wondering if you could use kron to
reboot the router. While it’s a good idea to use the command scheduler if you
want to reboot your router on a regularly scheduled basis, you can perform a
one-time delayed reboot using reload at
…. with less complexity.
uses for kron include clearing an
interface on a daily schedule, clearing the internal log, and showing the
routing table at set intervals and sending it to a log.
cases, you may want to log the failure or success of your commands. To do so, you
can use the debug command. For
example, to view all kron debugging, use
debug kron all. (You can also use more
specific kron debug commands.)
enabled debugging, send logging output to the router’s system buffer or to a
syslog server. In that log, you’ll find the command output and whether the
commands succeeded or failed.
These are just some examples of how you can use the IOS
command scheduler. How would you use the command scheduler on your network?
Post your ideas and tricks to this article’s discussion. For more information
about kron, check out Cisco’s
Command Scheduler Documentation.
David Davis has worked
in the IT industry for 12 years and holds several certifications, including
CCIE, MCSE+I, CISSP, CCNA, CCDA, and CCNP. He currently manages a group of
systems/network administrators for a privately owned retail company and
performs networking/systems consulting on a part-time basis.