一 shell脚本
#!/bin/bash redis-cli -a 123456 -n 0 keys "wbw_0_mid*" | xargs redis-cli -a 123456 -n 0 del sleep 0.1 redis-cli -a 123456 -n 0 keys "wbw_0_chan*" | xargs redis-cli -a 123456 -n 0 del sleep 0.1 redis-cli -a 123456 -n 0 keys "wbw_0_ch_mi_*" | xargs redis-cli -a 123456 -n 0 del sleep 0.1 redis-cli -a 123456 -n 0 ZREMRANGEBYRANK wbw_0_store_lock 0 -1 sleep 0.1
二 golangApi
router.POST("/Reset_wbw_redis", controller.Reset_lm_asa_sv)
func Reset_lm_asa_sv(ctx *gin.Context) { ... exec.Command("/bin/bash", utils.GlobalObject.Resetsh_path).CombinedOutput() ... ctx.JSON(http.StatusOK, resp) return }
用 exec.Command("/bin/bash", Resetsh_path).CombinedOutput() 命令不会有权限问题