This topic describes how to use redis-cli to run multiple commands at a time.
You can use redis-cli to run multiple commands and easily perform required tests.
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.
- 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.
- In the ECS instance in use
vi batchcmd.txtcommand creates a
. txtfile in which enter the batch execution of a command to save and exit command is used between the separated by a line break.
- 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
. txtin Redis commands.
cat ./batchcmd.txt | redis-cli -h [$Host] -a [$Password]The following command output is returned.
- [$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.
- ApsaraDB for Redis