cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
574
Views
4
Helpful
4
Replies

script to start afresh every 2 hours

Hi,

I'm trying to implement a script for a lab environment as follows:

1.- reload every 2 hours 

2.- when reloading, it must erase flash and erase startup-config

3.- after that, the IOS must be loaded from a TFTP

4.-- that means that the script must be saved on a TFTP, and will be executed every 2 hours from there.

Is it possible to achieve something like this? And if so, is there anything like this out there?

Kind Regards,

4 Replies 4

mfurnival
Level 4
Level 4

You can use Kron ( http://www.cisco.com/en/US/docs/ios/12_3/feature/guide/g_kron.html ) to schedule events such as this. I think you will have a problem with loading the IOS from TFTP each time after erasing the flash because after you erase the IOS from flash the router will go into ROMMON and sit there because you have no valid IOS in flash.

Hi mfurnival,

That's why I want to implement an EEM script on a TFTP server, containing KRON, in order to erase flash and startup-config and also load a new IOS from TFTP every 2 hours. This way, the script will not be erased, so it will be able to perform the same actions every 2 hours. The idea is that every 2 hours you get a fresh start with a router/switch, no matter was done in the previous time interval. 

Is there any EEM script like this out there?

Kind Regards,

Hi,

Kron will not work with interactive command like reload in for example, now why erase the  flash? just erase the startup config and copy the previous config from tftp server. You could even use the archive command to save the configs and rollback to initial one every 2 hours but you'll need an EEM script for this indeed.

Regards.

Alain

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.

Hi Alain,

I have been searching the web and I have found a couple of interesting things:

1.  You can force an applet to execute on a periodic basis. For example, if you want to do it every 2 hours, you must state this:

event manager applet Reload_in_2h
event timer cron name Reload_in_2h cron-entry "* 0-23/2 * * *"


So KRON command is not the only option.


2. As per the interactive one, you may use the 'typeahead' to state an answer in advance:
typeahead "y\ny" exec {reload}

  So the same may be applied to the erase commands.


3.You can translate an applet to a EEM script, in order to store it on tftp.
 

4a. And when it is time to execute it, you can bring it flash and do it from there,
   with an alias

     typeahead"\n"
     exec{copy tftp://192.168.1.10/tcl/my-script.tcl flash:my-script.tcl}
ios_config{alias exec sss tclsh flash:my-script.tcl}

4b.   Or even store your script in a tftp server and execute it straight from there, with an alias

      

           alias exec sss tclsh tftp:192.168.1.10/my-script.tcl   

               or  alias exec sss tclsh tftp://255.255.255.255/my-script.tcl

         

The aim of erasing the flash is to allow every new user to start afresh, allowing them to do whatever they want.

I am trying to put this all together but I am in a mess. So any help would be appreciated.

Regarding to your answer, that could be a secondary option. But I have a question:

if I enter the archive mode: could a user cancel it, so a new config-file would not be reloaded after the 2-hour interval?

Kind Regards,

Review Cisco Networking products for a $25 gift card