Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Shut down port wait 30 seconds enable port?

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

Everyone's tags (6)
1 REPLY
Cisco Employee

Shut down port wait 30 seconds enable port?

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"

1162
Views
0
Helpful
1
Replies