Kill: The Command to End All Commands
Suppose we had inadvertently started cat in the background; Ctrl-c would be ineffective, because the signal wouldn't get to the cat process. So we need to send it a signal some other way. With the command kill, you can send any signal to any process you own. The command's syntax is:
kill -SIGNAL
If no signal is specified on the kill command line, the terminate signal SIGTERM (default) is sent. This will normally terminate the process in question. If it fails to do so—that is, SIGTERM was caught or ignored—you can send the signal SIGKILL, which will always terminate the process.
Thus, we might do the following to terminate our runaway cat process commands. First determine the PID:
$ ps PID TT STAT TIME COMMAND 2037 p0 S 0:01 cat
Now, kill process 2037, which is the cat process:
kill 20371If cat had been written to catch SIGTERM, we would have to use a signal that cannot be caught or ignored.
kill -SIGKILL 20371In addition to killing errant processes, kill can be used to inform processes that the status of something has changed. For example, suppose you are writing a program and you wish to have it change its mode of operation on the occurrence of some external event. By coding what is called an “interrupt handler” in your program, you can have it catch any number of signals which have meaning to you. In particular, you might choose SIGUSR1 or SIGUSR2, which are non-specific. By sending your chosen signal, you can make your program aware of the change in circumstances, so it can proceed into its alternate mode of operation.
When you use kill, the desired signal is sent only to processes you own (that is, processes that you invoked). This prevents inadvertent termination of the wrong process. The exception is that the superuser (root) can use kill to send a signal to any process. Similarly, any process owned by root can send a signal to any other process.
An orderly shutdown of your system can occur in this way. While the kill command is not used at shutdown, the equivalent system call kill(2) is used to terminate everything. This guarantees that no files are left open and that all buffers are written to disk. For a description of kill(2), enter man 2 kill at the prompt.
A related command is killall, which takes the name of the process as an argument rather than the process ID (PID). (Some versions of kill can take process names too.) This is a convenient way to terminate all processes with the same name. If a path is used to identify the process to be signaled, only the processes executing that particular file are selected. In addition, you can ask to be consulted before killall kills a particular process, and you can receive confirmation that the signal was actually sent.
Although full details are listed in the man page, an example may be useful here. Suppose you have two programs that are different but have the same name—perhaps different release levels. In order to be different and have the same name, they must be stored in different directories. Assume they have the name sample_prog, but one is stored in /usr/a and the other in /usr/b. Entering ps gives the following output:
PID TTY STAT TIME COMMAND 123 pp0 S 0:03 /usr/a/sample_prog 124 pp1 R 0:02 /usr/b/sample_prog
The following commands perform different actions:
# To kill both processes killall sample_prog # To kill only process 123 killall /usr/a/sample_prog
In summary, the kill and killall commands can be useful tools to control the execution of processes on your Linux system. In combination with other tools described in previous “Take Command” columns, they will allow you to become true masters of a very powerful desktop appliance. For specific information on their very few options, and for a description of the signals they can invoke, read the relevant manual pages (enter man kill or man killall at the prompt).

Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
| Introduction to MapReduce with Hadoop on Linux | Jun 05, 2013 |
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- Linux Systems Administrator
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Validate an E-Mail Address with PHP, the Right Way
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- RSS Feeds
- Introduction to MapReduce with Hadoop on Linux
- user namespaces
16 min 44 sec ago - yea
42 min 33 sec ago - One advantage with VMs
3 hours 11 min ago - about info
3 hours 44 min ago - info
3 hours 45 min ago - info
3 hours 46 min ago - info
3 hours 48 min ago - info
3 hours 49 min ago - abut info
3 hours 51 min ago - info
3 hours 52 min ago
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
Kill child processes
I am trying to kill all child processes without the parent. Lets just say it is bash that is running multiple times. I want to kill all of the child processes for bash but leave the parent running. Does anyone know how I can do that. I have tried the multiple commands and they either don't work or they kill everything. Any suggestions?
Kill Commands
I am trying to kill all child processes without the parent. Lets just say it is bash that is running multiple times. I want to kill all of the child processes for bash but leave the parent running. Does anyone know how I can do that. I have tried the multiple commands and they either don't work or they kill everything. Any suggestions?
kill by process name
To kill by process name, use pkill -signal
pkill processname -signal
pkill processname -signal
I always thought that kill
I always thought that kill -SIGKILL would kill any process, until I started plugging USB drives into my machine. I keep having problems where they lockup and cannot be listed, unmounted or anything else. If I do an ls on the mounted file system, it never comes back. I can find the process id of the ls process, but kill -9 on that process id does nothing. Anyone have something stronger than kill -9?
i'm running leopard on my
i'm running leopard on my AlBook G4 1.5 how do you use the process name i.e. "safari" "firefox" in conjunction with kill/killall?