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?
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
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://220.127.116.11/%date%-config.txt
where %date% would be expanded to be a real date so the end result is
copy running-config tftp://18.104.22.168/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.
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.