killall

signal processes by command name

GNU version OS X
killall [-Z, --context pattern] [-r, --regexp] [-I, --ignore-case] [-e, --exact]
        [-u, --user user] [-g, --process-group] [-i, --interactive]
        [-o, --older-than time] [-y, --younger-than time]
        [-v, --verbose] [-w, --wait] [-q, --quiet] [-V, --version] [-s, --signal sig]   [--] command
killall -l
killall -V, --version

Sends a signal to processes running any of the specified commands. Default signal SIGTERM.
Signals can be specified by name (Example: -HUP or -sighup ) or by number (Example: 1) or by option -s.

If command is not regular expression and contains a slash (/), processes executing that file will be selected for signaling, independent of their name.

-i
--interactive
ask for confirmation before signaling.   good
-e
--exact
Require an exact match for long names.
If a command name is longer than 15 characters, the full name may be unavailable, and killall will signal all processes matching the first 15 characters!
With -e such entries are skipped and displays a message for each skipped entry if -v is specified
-I
--ignore-case
case insensitive process name match.
-u uid
--user uid
Signal processes the uid owns. command is optional!
-g g
--process-group g
Signal the process group to which the process belongs.
The signal is only sent once per group, even if multiple processes belonging to the same process group were found.
-o nn.nu (ago)
--older-than nn.nu (ago)
Match only processes that are older (started before) nn.nu.
The time is specified as a float then a unit. The units are s,m,h,d,w,M,y for seconds, minutes, hours, days, weeks, Months and years respectively.
-y nn.nu (ago)
--younger-than nn.nu (ago)
Match only processes that are younger (started after) …
-q
--quiet
Do not complain if no processes were killed.
-r
--regexp
Interpret process name pattern as an extended regular expression.
-l
--list
List all known signal names.
HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM URG STOP 
TSTP CONT CHLD TTIN TTOU IO XCPU XFSZ VTALRM PROF WINCH INFO USR1 USR2
-s
--signal sig
Send this signal default of SIGTERM.
-v
--verbose
Report if the signal was successfully sent.
-V
--version
Display version information.
-w
--wait
Wait for all signaled processes to die. Checks once per second if any of the signaled processes still exist and only returns if none are left.
Note that killall may continue to wait if signal was not TERM, was ignored, had no effect, or if the process stays in zombie state.
-Z
--context
(SELinux Only) Specify security context: signal only processes having security context that match with given expended regular expression pattern. Must precede other arguments on the command line. Command names are optional.

Returns a zero return code if at least one process has been signaled for each listed command, or no commands were listed and at least one process matched the -u and -Z search criteria.

killall never signals itself (but may signal other killall processes)!

Error messages

No matching processes belonging to you were found

Files

/proc location of the proc file system

KNOWN BUGS

Killing by file only works for executables that are kept open during execution, i.e. impure executables can't be signaled this way.

Be warned that typing killall name may not have the desired effect on non-Linux systems, especially when done by a privileged user.

killall --wait doesn't detect if a process disappears and is replaced by a new process with the same PID between scans.

If processes change their name, killall may not be able to match them correctly.

Limit of names that can be specified on the command line. This is the size of an unsigned long multiplied by 8. For most 32 bit systems the limit is 32 and similarly for a 64 bit system the limit is usually 64.

SEE ALSO

kill(1), fuser(1), pgrep(1), pidof(1), pkill(1), ps(1), kill(2)

BSD Mac OSX

killall [-delmsvz] [-help] [-u user] [-t tty] [-c procname] [-SIGNAL] [procname ...]

Issues a signal against processes (selected by name (as opposed to pid as with kill), with a real UID of the caller, matching procname.
The super-user is allowed to killall any or MANY process.

-s Show what would be done, (do not send signal).  good
-d
-v
verbose about what will be done.
For a single -d a list of processes that will be signaled is output
-u user processes belonging to user.
-e Effective user ID instead of the real user ID for match with -u
-t ttyn match processes on ttyn.
-c procname with -u or -t , match procname.
-m Match procname as a (case sensitive) regular expression.
> CAUTION! A single dot will match any process running under the real UID of the caller.
-help
 > killall -help
usage: killall [-delmsvz] [-help]
               [-u user] [-t tty] [-c cmd] [-SIGNAL] [cmd] …
At least one option or argument to specify processes must be given.
-l List signals i.e.:
HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM URG STOP TSTP CONT CHLD TTIN TTOU IO XCPU XFSZ VTALRM PROF WINCH INFO USR1 USR2 .
bash trap details these.
-SIGNAL sig Signal specified as a name (with or without leading SIG), or numerically(avoid) instead of the default TERM.
-z zombies are included. This should not have any effect except to output a few error messages if there are zombie processes that match the specified pattern.

ALL PROCESSES

Sending a signal to all processes with uid UID is supported by kill(1).
Example:
kill -hup -1
or
as root
$ echo kill -hup -1 | su -m user

EXIT STATUS

2 a command error.
1 no matching process found or not all processes have been signalled successfully.
0 will be returned.

DIAGNOSTICS

Diagnostic messages will only be printed if requested by -d

pgrep, pkill

find or signal processes by name

pgrep [-v] [-Lafilnoqx] [-F pidfile] [-G gid] [-P ppid] [-U uid] [-d delim] [-g pgrp] [-t tty] [-u euid] pattern

pkill [-v] [-signal] [-ILafilnox] [-F pidfile] [-G gid] [-P ppid] [-U uid] [-g pgrp] [-t tty] [-u euid] pattern

pgrep searches the process table and outputs the process IDs of processes that match the criteria

pkill " … " then sends a signal to them.

-v do not match the criteria. Must be first argument to pkill if included.

WARNING: As root specifying match poorly can kill MANY MANY Processes !

-signal sig signal number or name Default: TERM.
-I Request confirmation before signaling each process.
-F pidfile PID in pidfile
-L pidfile for -F must be locked with the flock(2) syscall or created with pidfile(3).
Restrict matches to processes in the list of:
-G gid[, gid … ] real group IDs
-P ppid[, ppid …] parent process ID
-U uid[, uid …[ real user ID
-u euid[, euid …] effective user ID
-g pgrp[, pgrp …] process group ID .
zero means the process group ID of the running pgrep or pkill
-t tty[, tty …] associated with terminals in the form ttynn or nn.
A dash (-) matches processes not associated with a terminal.

WARNING: As root specifying match poorly can kill MANY MANY Processes !

-n Select newest (most recently started) of the matches
-o Select oldest of the matches
-i Ignore case in the process table and pattern.
-a Include process ancestors in the match list.
By default, the current pgrep or pkill process and all of its ancestors are excluded (unless -v is used).
-f against full argument lists. The default is to match against process names.
-x Require an exact match of the process name, or argument list if -f is given. The default is to match any substring.
-l Long output.
For pgrep output the process name in addition to the ID for matching process.
With -f output the process ID and the full argument list for matching process.
For pkill display the command used for each process
-d delim delimiter between process IDs for pgrep. default :newline.
-q Quite. Do not write anything to standard output.

Examples

> ps -e|g Stocks                   
88601 ??         0:30.39 /System/Applications/Stocks.app/Contents/PlugIns/StocksWidget.appex/Contents/MacOS/StocksWidget
> sudo killall -s -v  StocksWidget  -hup 
kill -hup 88601

Pattern operands are used as regular expressions to match the command name or full argument list.
Does not match itself.

EXIT STATUS

0 One or more processes were matched.
1 No processes were matched.
2 Invalid options were specified on the command line.
3 An internal error occurred.

SEE ALSO

kill, killall, ps, flock, sigaction, pidfile, re_format