Cron? no Kron :)

Cron is a time-based job scheduler in Unix-like computer operating systems. The name cron comes from the word “chronos”, Greek for “time”. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. It is commonly used to automate system maintenance or administration, though its general-purpose nature means that it can be used for other purposes, such as connecting to the Internet and downloading email.

What can I use to schedule a script or a command in Cisco? The kron feature :)

Kron provides the ability to schedule some EXEC command-line interface (CLI) commands to run at specific times or at specified intervals.

Use Kron feature is very simple and it is based on two steps:

  1. Define the policy with the commands that will be executed:
    1. enable
    2. configure terminal
    3. kron policy-list list-name
    4. cli command
    5. -Repeat Step 4 for all EXEC CLI to run at the same time or interval-
    6. exit
  2. Define the policy occurrences:
    1. enable
    2. configure terminal
    3. kron occurrence occurrence-name [user user-name] {in [[numdays:]numhours:]nummin | at hours:min [[month] day-of-month] [day-of-week]} {oneshot | recurring}
    4. policy-list list-name
    5. -Repeat Step 4 for all policies to run at the same time or interval-
    6. end

 

Example #1:
In this example, I save the running-configuration to the startup-configuration each 4 hours:

Ciscozine(config)#kron policy-list save
Ciscozine(config-kron-policy)#cli write
Ciscozine(config-kron-policy)#exit
Ciscozine(config)#
Ciscozine(config)#kron occurrence four-hours in 04:00
Ciscozine(config-kron-occurrence)#policy-list save
Ciscozine(config-kron-occurrence)#exit
Ciscozine(config)#
Ciscozine#sh kron schedule
Kron Occurrence Schedule
four-hours inactive, will run again in 0 days 03:59:40

Ciscozine#

Example #2:
In this example, I disable the debug command at midnight (0:00):

Ciscozine(config)#kron policy-list nodebug
Ciscozine(config-kron-policy)#cli undeb all
Ciscozine(config-kron-policy)#exit
Ciscozine(config)#
Ciscozine(config)#kron occurrence midnight at 00:00
Ciscozine(config-kron-occurrence)#policy-list nodebug
Ciscozine(config-kron-occurrence)#exit
Ciscozine#show kron schedule
Kron Occurrence Schedule
midnight inactive, will run again in 0 days 06:02:49 at 0 :00 on
Ciscozine#

Below the video with the two examples:

 

References:

1 COMMENT

  1. Hi there, how do I Kron via https / scp to a windows 2012 IIS box? (tftp & ftp are no secure enough options). Thanks in advance.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.