cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3503
Views
0
Helpful
1
Replies

Shut down port wait 30 seconds enable port?

roger perkin
Level 2
Level 2

I need to write a small scrip that will shut a port down, wait 30 seconds and then bring the port back up again.

The reason is that shutting the port down will cut me off, it will enable some routing to converge properly and then I need the port bringing back up again.

I think something along the lines of this

action 1.1 cli command "enable"

action 1.2 cli command "conf t"

action 1.3 cli command "interface g0/0"

action 1.4 cli command "shut"

action 1.5 cli command "end"

action 1.6 syslog msg "Interface GigabitEthernet 0/1 shutdown"

action 1.7 - wait 30 seconds?

action 2.1 cli command "enable"

action 2.2 cli command "conf t"

action 2.3 cli command "interface g0/0"

action 2.4 cli command "no shut"

action 2.5 cli command "end"

Many Thanks

Roger

1 Reply 1

Joe Clarke
Cisco Employee
Cisco Employee

This depends on your version of IOS.  You could do this with the "wait" action, but that will only work with EEM 3.0 and higher (plus you'd need to increase your maxrun time).  A way that will work with all versions of EEM is using two applets:

event manager environment q "

!

action 1.1 cli command "enable"

action 1.2 cli command "conf t"

action 1.3 cli command "interface g0/0"

action 1.4 cli command "shut"

action 1.5 syslog msg "Interface GigabitEthernet 0/1 shutdown"

action 1.6 cli command "event manager applet noshut-countdown"

action 1.7 cli command "event timer countdown time 30"

action 1.8 cli command "action 1.0 cli command enable"

action 1.9 cli command "action 2.0 cli command $q config t$q"

action 2.0 cli command "action 3.0 cli command $q interface g0/0$q"

action 2.1 cli command "action 4.0 cli command $q no shut$q"

action 2.2 cli command "action 5.0 cli command $q no event manager applet noshut-countdown$q"

action 2.3 cli command "end"

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