Aruba Intelligent Edge Switches - How To Repeat Multiple Commands In The Switch CLI

By esupport posted Aug 27, 2020 04:56 PM

  
Q:

Can I repeat multiple commands at the same time in the switch CLI?



A:

The “Repeat” command can be used to allow a single command or a multiple set of commands to repeatedly run in the switch Command Line Interface (CLI).

The “repeat” command is most often used to repeat the last command that was typed into the CLI.  This will continue to repeat until “CTRL + C” is pressed to stop the output.  However, there are also additional options available that can make the output more useful.

The options available with the “repeat” command are shown in the following screenshot:

The “CMDLIST” option allows you to select which command (or commands) you want to repeat from the command history.
The “count” option allows you to have the command(s) run a specific number of times.
The “delay” option allows you to set the time delay (in seconds) between each repeat.
 

CMDLIST:
To view the most recent commands listed in the command history (CMDLIST), run the “show history” command.  It will list the most recent commands along with a number associated with each command.  Here is a screenshot with 8 commands that were run during this session:

The last 8 commands that were run are listed in descending order, with oldest to most recent.  The last (most recent) command to be run was “show time” and the oldest command to be run was “show run”.

If I type in “repeat” with no other options, it would continue to repeat the “show time” command.  By default, the “repeat” command will run the command listed in the CMDLIST number 1 location.
If I want to repeat the “show cpu” command, I would run the “repeat 2” command, which would repeat the command located in the CMDLIST number 2 location.
If I want to repeat both the “show time” and “show cpu” commands, I would run the commands in the CMDLIST number 1 and number 2 locations.  An example of this is shown in the following screenshot:

* Note, these commands will continue to repeat until the “CTRL + C” buttons are pressed to stop the repeat process.
You can see that it first ran the “show time” command and secondly ran the “show cpu” command.  It then repeatedly runs these two commands until you stop the process.


Count:
The “count” option allows the output to stop after a specified number of repeats.
In this example, the “count” was set to 1, so it stopped the repeat output after 1 time.

If I want to run this 500 times and then stop the output, I would type in “repeat 1,2 count 500”.
 

Delay:
The “delay” option allows you to specify how many seconds to wait before repeating the command(s) again. 
Without configuring a delay, it will repeat approximately every 3 seconds.
In this example, I set the delay to 60, which allows the last 2 commands to repeat every 60 seconds:

Allowing multiple commands to run repeatedly, is useful when you want to monitor specific output for an extended period of time.  This output can be saved to a log file so it can be reviewed at a later time.  Adding the "show time" command allows the time and date to be placed into the output so it can be compared to data or graphs shown in many network monitoring applications. 

In the screenshot examples above, I was running the “show time” and “show cpu” output to compare with a network monitoring application that would notify me the CPU was high for a couple minutes and this seemed to occur once or twice a week at random times.  Capturing the output every 3 seconds for many days would create a larger log file, so I used the “delay” option to have it run once every minute, rather than the default of approximately 20 times per minute. The next time the network monitoring application reported high CPU on the switch, I was able to view the log output and see what CPU processes were running at that time and date to help me further troubleshoot the cause.
 

All 3 options at the same time:
All 3 options can be used at the same time. 
For example, if I want to repeat the last 3 commands in the command history, 1000 times, at a 30 second interval, I would use the following syntax:
  repeat 1,2,3 count 1000 delay 30
This would run the last 3 commands, wait 30 seconds and repeat this process 1000 times before it ends.  I could also press “CTRL + C” to stop this process sooner if desired.

0 comments
29 views