HxHippy

kill

Send a signal to a process

Overview

Sends the specified signal to the specified process or process group. If no signal is specified, the TERM signal is sent, which normally kills processes.

Syntax

kill [OPTION]... PID...
kill -l [SIGNAL_NUMBER]

Common Options

-s SIGNAL, --signal SIGNAL

Specify the signal to send (name or number, e.g., -9 or -KILL). Defaults to SIGTERM.

-SIGNAL_NUM or -SIGNAL_NAME

Specify signal by number (e.g., -9) or name (e.g., -TERM). This is POSIX compliant.

-l, --list

List all known signal names, or convert a signal number to its name.

Common Signals:

1 (SIGHUP - Hangup), 2 (SIGINT - Interrupt), 9 (SIGKILL - Kill), 15 (SIGTERM - Terminate), SIGSTOP (Stop process), SIGCONT (Continue stopped process).

Examples

$ kill 12345

Sends the default SIGTERM (15) signal to process ID 12345, requesting it to terminate.

$ kill -9 54321

Forcibly terminates process ID 54321 using SIGKILL.

$ kill -SIGKILL 54321

Another way to forcibly terminate process ID 54321.

$ kill -l

Lists all available signal names.

$ kill -l 15

Prints the name of signal 15 (which is TERM).

$ kill -s SIGHUP 6789

Sends the SIGHUP signal to process ID 6789 (often to reload configuration).

$ kill -TERM $(pidof my_server)

Sends SIGTERM to the process ID returned by `pidof my_server`.

$ pkill -f process_name

(Related command) Kills processes whose name matches process_name. Uses SIGTERM by default.

$ killall nginx

(Related command) Kills all processes named nginx. Uses SIGTERM by default.

terminatestopprocesssignalkillpid