Schedule commands with Cisco IOS' kron
Takeaway: Command schedulers allow you to run commands, or a sequence of commands, once or on a recurring calendar. Learn how you can use the Cisco IOS command scheduler to back up your router's running configuration to the startup configuration on a regular basis.
Want to learn more about router and switch management? Automatically sign up for our free Cisco Routers and Switches newsletter, delivered each Friday!
Cisco IOS 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.
Command schedulers 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
For 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.
The new IOS command scheduler makes this a relatively easy task. Here's how you can use kron to accomplish this.
First, 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
Next, 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
This code sets up your backup job to run every Monday night at 10 P.M. (22:00 in military time).
Finally, 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)
You might 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
Another 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.
In 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.
Some of 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
You might 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.
Additional 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.
In some 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.)
Once you've 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.
Print/View all Posts Comments on this article
|
|
|
|
|
|
|
|
White Papers, Webcasts, and Downloads
- Total Economic Impact of SQL Server 2008 Upgrade Microsoft See how upgrading to Microsoft SQL Server 2008 can provide your company with an anticipated ROI of between 160 and 180 percent. Download Now
- Webinar: Best Practices for Windows 7 Application Compatibility Flexera Software Are your business-critical applications compatible with Windows? 7? Join ... Download Now
- Enabling Device-Independent Mobility with Dynamic Virtual Clients Intel Intel IT is investigating a model where users can access their ... Download Now
- Sole-sourcing BI from your ERP vendor: IT convenience or strategic business decision? IBM Is sole-sourcing BI from ERP vendors delivering on its promises? See what 100 companies worldwide had to say about this increasingly common practice. Download Now
- Driving business agility through SOA connectivity and integration IBM Corp. This paper describes some of the business and IT issues that enterprises ... Download Now
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET

