Linux command
killall 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Terminate all processes
killall [process_name]
Force kill processes
killall -9 [process_name]
Send a specific signal
killall -s [SIGTERM] [process_name]
Kill only processes owned by you
killall -u $(whoami) [process_name]
Interactive mode
killall -i [process_name]
Kill processes matching regex
killall -r "[pattern]"
Verbose mode
killall -v [process_name]
Wait for processes to terminate
killall -w [process_name]
List all known signal names
killall -l
Kill processes older than
killall -o 1h [process_name]
说明
killall sends a signal to all processes running the specified command. Unlike kill which requires process IDs, killall works with process names, making it convenient for terminating multiple instances of a program. By default, killall sends SIGTERM (signal 15), which requests graceful termination. Processes can catch this signal and clean up before exiting. Use SIGKILL (-9) when processes don't respond to SIGTERM, but be aware this prevents cleanup. Name matching compares against the command name (visible in ps). The -r flag enables regex matching for flexible patterns. With -i, you're prompted before each process is killed. The -w flag makes killall wait until all processes are actually terminated before returning. This is useful in scripts where you need to ensure processes are stopped before proceeding. Time-based filtering (-o, -y) allows killing only processes that have been running longer or shorter than specified duration (e.g., "1h" for one hour, "30m" for 30 minutes, "1d" for one day).
参数
- -e, --exact
- Require exact name match for very long names. By default, killall truncates names to 15 characters.
- -I, --ignore-case
- Case-insensitive matching.
- -i, --interactive
- Ask for confirmation before killing.
- -l, --list
- List known signal names.
- -q, --quiet
- Don't complain if no processes were killed.
- -r, --regexp
- Interpret names as extended regular expressions.
- -s, --signal _signal_
- Send specified signal (name or number).
- -u, --user _user_
- Kill only processes owned by user.
- -g, --process-group
- Kill the process group instead of process.
- -v, --verbose
- Report if signal was successfully sent.
- -w, --wait
- Wait for killed processes to terminate.
- -o, --older-than _time_
- Kill processes older than specified time.
- -y, --younger-than _time_
- Kill processes younger than specified time.
- -n, --ns _PID_
- Match against the PID namespace of the given PID.
- -V, --version
- Display version information.
- -Z, --context _pattern_
- Kill only processes with matching SELinux context (SELinux only).
FAQ
What is the killall command used for?
killall sends a signal to all processes running the specified command. Unlike kill which requires process IDs, killall works with process names, making it convenient for terminating multiple instances of a program. By default, killall sends SIGTERM (signal 15), which requests graceful termination. Processes can catch this signal and clean up before exiting. Use SIGKILL (-9) when processes don't respond to SIGTERM, but be aware this prevents cleanup. Name matching compares against the command name (visible in ps). The -r flag enables regex matching for flexible patterns. With -i, you're prompted before each process is killed. The -w flag makes killall wait until all processes are actually terminated before returning. This is useful in scripts where you need to ensure processes are stopped before proceeding. Time-based filtering (-o, -y) allows killing only processes that have been running longer or shorter than specified duration (e.g., "1h" for one hour, "30m" for 30 minutes, "1d" for one day).
How do I run a basic killall example?
Run `killall [process_name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -e, --exact do in killall?
Require exact name match for very long names. By default, killall truncates names to 15 characters.