1000 Ways to Die (`kill`)
kill, and its sister killall, are likely familiar to you already. They are simple tools to send signals to a process. Most commonly they are used to end processes with the TERM signal.
Signals we care about:
TERM: Cleanly exit a process, like a CTL+C.HUP: 'Hang up,' many services such as databases use this signal as a notice to restart without terminating. Eg, for a configuration change.KILL: Harshly exit a process, without allowing graceful shutdown.STOP: Pause a process, like a CTL+Z.CONT: Resume a process.
kill requires a PID (such as from ps), while killall supports process names.
Terminating a process:
killall apacheSending a specific signal:
killall -s HUP postgresPausing a process for several seconds:
killall -s STOP tikv-server
sleep `shuf -i 1000-10000 -n 1`
killall -s CONT tikv-serverExercises
Try sending
STOPto a runningapache2server. Do requests still work? Now sendCONTand test again, does it work again?Open a psql shell (
sudo -u postgres psql), try sending anHUPtopostgresusing another shell, does yourpsqlshell stop working? What about when you sendKILL?
Last updated