Introduction
This topic describes how to use redis-cli to run multiple commands at a time.
Background
You can use redis-cli to run multiple commands and easily perform required tests.
Background information
In the actual running environment, especially before your system begins normal operations, you may perform several tests. For some tests, you need to modify data in apsaradb for Redis. You may be required to perform the Redis command writes a . txt
file by redis-cli batch execution in the file command to achieve small-scale or temporary data modification and testing.
Prerequisites
- An Alibaba Cloud environment is available, that is, at least one ECS instance and one Redis instance can communicate with each other.
- ECS instances use Linux.
Procedure
- In the ECS instance in use
vi batchcmd.txt
command creates a. txt
file in which enter the batch execution of a command to save and exit command is used between the separated by a line break.
Note:
- You can use any command of the same effect to perform this step, and can use any file name, such as batchcmd.txt.
- The system sequentially runs the commands in the batchcmd.txt file in the same way as you run multiple commands in the Linux command-line interface (CLI).
- Use the following command batch execution
. txt
in Redis commands.cat ./batchcmd.txt | redis-cli -h [$Host] -a [$Password]
The following command output is returned.
Note:
- [$Host] is the connection address of the apsaradb for Redis instance.
- [$Password] is the authentication Password of the Redis instance.
- The CLI outputs the result of each command line by line.
Application scope
- ApsaraDB for Redis