opscape

Processes and jobs

killall

Send a signal (TERM by default) to all processes running a program with the given name.

killall [-SIGNAL | -s SIGNAL] [OPTION...] NAME...

10 of 10 examples run in Debian 13.7 on 2026-10-31 · manual: killall(1)

killall signals every process whose name equals the one you give: killall firefox stops every Firefox process you own. Unlike pkill, the name is matched whole, not as a pattern, so killall ssh does not touch sshd. Regular expressions are available with -r, but only on request. It also has a few conveniences pkill lacks: -i asks before each kill, -w waits until the processes are actually gone, and -o/-y select by age (-o 2h, older than two hours).

On Linux, killall comes from psmisc and is safe to type. On Solaris and some older System V Unixes, a command with the same name kills all processes on the system, as part of shutdown; that is why some administrators avoid the name entirely in scripts meant to be portable and use pkill -x instead.

Signals are given as -HUP, -9, -s KILL or --signal KILL. -v reports each process signaled, and the exit status is 0 if every name matched something and 1 otherwise.

Examples

Stop every process with a given name

sleep 300 & sleep 600 &
killall -v sleep
output
Killed sleep(1311) with signal 15
Killed sleep(1312) with signal 15

Both sleep processes receive TERM (signal 15). Without -v the command is silent on success.

Nothing to kill

killall nginx
explain
outputexit 1
nginx: no process found

no process found on standard error and exit status 1. Add -q to suppress the message when "already stopped" is an acceptable outcome, and || true if the script runs with set -e.

Whole names only

sleep 300 &
killall slee; echo "exit status: $?"
killall -v sleep
output
slee: no process found
exit status: 1
Killed sleep(1315) with signal 15

slee is not the name of any process, so nothing is killed; pkill slee would have matched sleep. This is the main reason to choose killall when you know the exact program name.

Send a different signal

sleep 300 & sleep 301 &
killall -v -HUP sleep
output
Killed sleep(1318) with signal 1
Killed sleep(1319) with signal 1

-HUP, -1, -s HUP and --signal HUP are equivalent; -v shows signal 1 went out. sleep has no handler, so HUP ends it; a daemon with a HUP handler would reload instead.

Wait until the processes have exited

slowstop.sh
#!/bin/bash
trap 'echo "cleaning up..."; sleep 1; echo "done"; exit 0' TERM
while :; do sleep 0.1; done
chmod +x slowstop.sh
./slowstop.sh &
sleep 0.3
killall -w slowstop.sh
echo "killall returned"
output
cleaning up...
done
killall returned

The script takes a second to clean up after TERM. -w makes killall wait until every signaled process has exited, so the next command (a restart, say) does not start too early. Without -w it would return at once.

Confirm each kill

sleep 300 & sleep 600 &
printf 'y\nn\n' | killall -i sleep
pgrep -a sleep
output
Kill sleep(1330) ? (y/N) Kill sleep(1331) ? (y/N) 1331 sleep 600

-i asks Kill sleep(PID) ? (y/N) for each process. The answers come from the pipe here (so the prompts run together on one line): y for the first, n for the second, and only sleep 600 remains.

Kill only processes older or younger than a given age

sleep 300 &
killall -v -o 1h sleep; echo "older than 1h: exit $?"
killall -v -y 1m sleep
output
sleep: no process found
older than 1h: exit 1
Killed sleep(1335) with signal 15

-o matches processes started more than the given time ago, -y less. Units are s, m, h, d, w, M (months) and y. The sleep started a moment ago, so it is not older than an hour but is younger than a minute.

Match names with a regular expression

sleep 300 &
python3 -c 'import time; time.sleep(300)' &
sleep 0.2
killall -v -r '^(sleep|python3)$'
output
python3(1): Operation not permitted
Killed sleep(1338) with signal 15
Killed python3(1339) with signal 15

-r treats each name as an extended regular expression. Anchor it, or -r py would also match any other name containing py. The sandbox's own runner is a root-owned python3 process (PID 1); killall may not signal it, says so, and carries on with the others.

Kill everything a user is running

sleep 300 & sleep 301 &
killall -v -u dev sleep
output
Killed sleep(1342) with signal 15
Killed sleep(1343) with signal 15

-u USER restricts the match to that user's processes. As root, killall -u alice without a name signals all of alice's processes, which ends her sessions.

List the signal names killall knows

killall -l
explain
output
HUP INT QUIT ILL TRAP ABRT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM STKFLT
CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH POLL PWR SYS

The signal names in number order, without the SIG prefix: HUP is 1, INT 2 and so on. Use them with -s or as -NAME.

Common pitfalls

  • Typing killall on Solaris or another System V Unix. There it kills every process on the machine. For scripts that might run anywhere, pkill -x name is the safer spelling.

  • Long names. The kernel keeps only 15 characters of a process name; when psmisc cannot read the full name it falls back to matching those 15 characters, so killall my-service-worker can hit my-service-work-other. -e skips such uncertain matches.

  • Scripts started through an interpreter are named after their file only when run through the #! line (./worker.sh). Started as bash worker.sh or python3 worker.py, their name is bash or python3, and killall python3 hits every Python program you run.

  • Expecting killall to have finished the job when it returns. Without -w it only sends the signal; processes that handle TERM may take time to exit.

GNU vs BSD and macOS

The examples above ran the GNU/Linux version. These are the differences that matter on macOS and the BSDs (written from their documentation, not run here).

  • macOS and FreeBSD have their own killall, also safe (it kills by name), with a different option set: -s there means "show what would be done" rather than "signal". Use killall -SIGNAL name or -HUP style, which both versions accept.

Options worth knowing

A selection, described in our own words. For the full list, see killall(1) or killall --help.

OptionWhat it does
-vReport each process that was signaled.
-qDo not complain when no process matches.
-s SIGNALSend SIGNAL (name or number) instead of TERM.
--signal SIGNALLong form of -s.
-lList the known signal names.
-iAsk for confirmation before each kill.
-wWait until all signaled processes have exited.
-eRequire an exact match for names longer than 15 characters.
-IMatch process names case-insensitively.
-rTreat each name as an extended regular expression.
-u USERKill only processes owned by USER.
-o TIMEMatch only processes older than TIME (e.g. 30m, 2h, 1d).
-y TIMEMatch only processes younger than TIME.
-gSignal the whole process group of each matching process.
-n PIDMatch only processes in the same namespaces as PID.
-9Send KILL, which cannot be caught or ignored.
-KILLSend KILL by name.
-HUPSend HUP, usually a request to reload configuration.
-TERMSend TERM, the default.
-INTSend INT, the same as pressing Ctrl-C.
-USR1Send USR1, whose meaning each program defines.

Related