15

I am going through a tutorial on recovering from a database failure and in the tutorial, a failure on the host of the primary database is simulated with:

kill -9 <>

I know that the kill command is used to send a signal to a process, and that 9 represents the SIGKILL signal that terminates a process, but what does the <> argument stand for?

I have read the manual pages for the kill command but still cannot figure out why and what for <> is used.

  • 7
    Can you add the link to the tutorial? The first thing that comes to mind, is that the author of that post wants you to replace the <> characters with a specific process id. – Dan Feb 14 '18 at 9:56
  • 20
    It looks like the author of the site messed up with HTML strings. The source code has: kill&nbsp;-9 &lt;<pid for="" nbsp="" postmaster="" process="">&gt;</pid>, so they probably wrote kill -9 <pid> and some funny editor did all the magic to create a <pid> tag. – fedorqui Feb 14 '18 at 12:07
  • 9
    @fedorqui, <pid for="" nbsp="" postmaster="" process="">, that makes perfect sense! It's meant to say "pid for postmaster process" and it is the main PostgreSQL PID to kill. So the post was meant to say kill -9 <pid for postmaster process> Mystery solved. – dw8547 Feb 14 '18 at 13:30
  • 9
    Heads up: Don't make kill -9 a habit. Just use kill. SIGTERM lets the process shut down gracefully. SIGKILL (-9) is the nuclear option. – John Kugelman Feb 14 '18 at 15:22
  • @fedorqui: I'm pretty sure it was kill -9 <<pid>>. – Joshua Feb 14 '18 at 16:52
16

You're supposed to replace the <> by the process id. To get the process id, you can use the command

ps -aux

It will list all the processes, and you just have to choose the right process

If you have a single instance of a process, you can also use the pkill commmand with the name of the process, eg

pkill -9 mysql
  • 1
    ... and if there are multiple instances, you can use killall. Also, if you want the PID, pgrep saves hunting through ps output – Zanna Feb 14 '18 at 10:06
  • 3
    @Zanna pkill actually kills all the processes that match, not just one. – Dan Feb 14 '18 at 10:10
  • 7
    keep in mind that pkill would kill any process containing the mysql word. For example, if you have a process called mysql and another mysql-python (just an example) both would be killed with that command. – Dan Feb 14 '18 at 10:11
3

It is

<pid> [...]
      Send signal to every <pid> listed.

in manpage. There is always description inside of the <> quotes.

2

<> in the man page means replace <> with PID.

In addition to the answer by Felicien using the ps command, you can also use top or htop

top -d 10

Use -d <> (duration) to update every <> seconds.

To kill the process, simply note the PID and kill the process ID with:

kill -9 xxxx

Note: for htop, you will need to type htop -d 100 ie; 10 seconds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.