# 错误：SCRIPT KILL失败 - 当前没有正在执行的脚本

- **ID:** `redis/redis-script-kill-failed-no-script-running`
- **领域:** redis
- **类别:** runtime_error
- **错误码:** `ERR`
- **验证级别:** ai_generated
- **修复率:** 92%

## 根因

用户尝试执行SCRIPT KILL时，没有正在执行的Lua脚本，可能是因为脚本已经完成或服务器不忙碌。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| redis 6.0 | active | — | — |
| redis 6.2 | active | — | — |
| redis 7.0 | active | — | — |
| redis 7.2 | active | — | — |

## 解决方案

1. ```
   Verify script execution status with `CLIENT LIST` to see if any client is executing a script (look for 'script' flag). If no script is running, the error is harmless; ignore it.
   ```
2. ```
   If a script appears stuck but SCRIPT KILL fails, use `MEMORY DOCTOR` to check for memory issues or `SLOWLOG GET` to find long-running commands that may be blocking.
   ```
3. ```
   Set a Lua script timeout in redis.conf: `lua-time-limit 5000` (5 seconds) to prevent scripts from running indefinitely, reducing the need for manual SCRIPT KILL.
   ```

## 无效尝试

- **Repeatedly calling SCRIPT KILL until it works** — Calling SCRIPT KILL when no script is running just returns the same error each time; it does not help kill a script that may have already ended. (95% 失败率)
- **Restarting Redis to clear any phantom scripts** — Restarting is unnecessary if no script is running; it causes downtime and may not address the real issue (e.g., a script that finished but left side effects). (70% 失败率)
- **Using SHUTDOWN NOSAVE to force stop** — SHUTDOWN NOSAVE is a drastic measure that discards all data; it is only needed when a script is stuck and SCRIPT KILL is refused, not when no script is running. (85% 失败率)
