cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4328
Views
5
Helpful
7
Replies

ios kron system variables

Erick Bergquist
Level 6
Level 6

Does the IOS kron feature have system variables we can use in commands it issues?

I am looking to schedule a command (ephone-hunt statistics write-all url/filename) but am needing to customize the filename and was hoping i could use a variable to use the current date/time as part of the filename so it is unique.

Any ideas? Would EEM be able to do this?

7 Replies 7

Joe Clarke
Cisco Employee
Cisco Employee

EEM would be more suited to doing this. You can write an EEM timer policy using a cron timer, and customize the input using EEM environment variables. For example:

event manager environment hunt_stats_filename flash:/file_1.txt

See http://www.cisco.com/en/US/products/ps6441/products_configuration_guide_chapter09186a00807c676c.html for more in EEM.

Ok, I looked over that doc again (found it earlier) and there doesn't seem to be a time and/or date variable.

What I am basically looking for is to make the URL unique each time the command runs. So the filename (part of URL) is different.

So, for example, the router command would be like. I am using copy running-config to keep it simple for everyone.

copy running-config tftp://1.2.3.4/%date%-config.txt

where %date% would be expanded to be a real date so the end result is

copy running-config tftp://1.2.3.4/08172007-config.txt

or something similar. Then run it runs again the filename would be 08182007-config.txt and then 08192007-config.txt and so on.

Here's an EEM TCL policy I wrote a while ago that does pretty much what you just described. Instead of TFTP, though, it uses FTP. It is a timer policy that requires a few environment variables to be set:

cc_cron_entry : Cron entry specifying when to run the policy

cc_ftp_server : Hostname or IP address of the FTP server

cc_ftp_path : Destination path on the FTP server

cc_ftp_user : (optional) Username for the FTP server

cc_ftp_pass : (optional) FTP user password

You should be able to modify this policy for your needs.

Thanks for sharing. I'll play with this and post back my TCL once I get what I need working. Are there any other tcl files I need to load on the flash (doesn't look like it, but this is my first time using EEM).

Do you mind sharing the eem config lines?

This script requires no other supporting libraries. To register it, make a directory on flash called policies, then set the required environment variables based on the values you require. Then:

event manager directory user policy "flash:/policies"

event manager policy config_copy_policy.tcl type user

After that, it will run based on the cc_cron_entry environment variable value.

Hello Guys!

I'm new with Cisco and EEM. I'm check your policy script, but I don't know how to edit it.

Can you explain me, I have to edit the archieve directly our I need do another thing in my equipment.

Hello,

I tried it but get the following error:

007757: Jun 19 15:44:20.006: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: 1Process Forced Exit- MAXRUN timer expired.
007758: Jun 19 15:44:20.007: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: while executing
007759: Jun 19 15:44:20.007: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: "if {[catch {cli_exec $clil(fd) $copy_cmd} result]} {
007760: Jun 19 15:44:20.007: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: error $result $errorInfo
007761: Jun 19 15:44:20.007: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: }"
007762: Jun 19 15:44:20.007: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: invoked from within
007763: Jun 19 15:44:20.007: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: "$slave eval $Contents"
007764: Jun 19 15:44:20.008: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: (procedure "eval_script" line 7)
007765: Jun 19 15:44:20.008: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: invoked from within
007766: Jun 19 15:44:20.008: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: "eval_script slave $scriptname"
007767: Jun 19 15:44:20.008: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: invoked from within
007768: Jun 19 15:44:20.008: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: "if {$security_level == 1} { #untrusted script
007769: Jun 19 15:44:20.008: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: interp create -safe slave
007770: Jun 19 15:44:20.008: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: interp share {} stdin slave
007771: Jun 19 15:44:20.009: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: interp share {} stdout slave
007772: Jun 19 15:44:20.009: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: ..."
007773: Jun 19 15:44:20.009: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: (file "tmpsys:/lib/tcl/base.tcl" line 50)
007774: Jun 19 15:44:20.009: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: Tcl policy execute failed:
007775: Jun 19 15:44:20.009: %HA_EM-6-LOG: 12118-config_copy_policy.tcl: 1Process Forced Exit- MAXRUN timer expired.

Any ideas?

Thanks,

Alexei

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco