redis SCRIPT KILL command
Translation results:
script
英[skrɪpt] 美[skrɪpt]
n.Script, handwriting; written typeface; script, broadcast script or movie script
vt.Write a script for a movie (or drama, etc.); make up
Third person singular: scripts Plural: scripts Present participle: scripting Past tense: scripted Past participle: scripted
kill
英[kɪl] 美[kɪl]
vt.& vi. Kill...
vt. Stop [end, fail]; destroy , weaken, offset; cause pain, cause torture; make one laugh to death, make one laugh to death
n. kill; hunt; hunted animal; prey
adj. fatal
Third person singular: kills Present participle: killing Past tense: killed Past participle: killed
redis SCRIPT KILL commandsyntax
Function:Kill the currently running Lua script. This command will take effect if and only if this script has not performed any write operations. This command is mainly used to terminate a script that takes too long to run, such as a script that loops infinitely due to a bug, and so on.
Syntax: SCRIPT KILL
Description: SCRIPT KILL After execution, the currently running script will be killed, and the client executing this script The client will exit from blocking on the EVAL command and receive an error as the return value. On the other hand, if the currently running script has already performed a write operation, it cannot be killed even if SCRIPT KILL is executed, because this violates the atomic execution principle of Lua scripts. In this case, the only feasible way is to use the SHUTDOWN NOSAVE command to stop the script from running by stopping the entire Redis process and prevent half-written information from being written to the database.
Available versions: >= 2.6.0
Time complexity: O(1)
Return: Return OK if the execution is successful, otherwise an error will be returned.
redis SCRIPT KILL commandexample
# 没有脚本在执行时 redis> SCRIPT KILL (error) ERR No scripts in execution right now. # 成功杀死脚本时 redis> SCRIPT KILL OK (1.30s) # 尝试杀死一个已经执行过写操作的脚本,失败 redis> SCRIPT KILL (error) ERR Sorry the script already executed write commands against the dataset. You can either wait the script termination or kill the server in an hard way using the SHUTDOWN NOSAVE command.