Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 
 

Kill a Process

Linux Tips by Burleson Consulting

When good processes go bad it is often necessary to terminate them.  The kill command is used to send a termination signal to the specified process or group. The default termination signal is a SIGTERM (15) signal.  A process which receives a SIGTERM may be programmed to trap signals and perform specific functions or ignore the signal entirely.

kill takes a process ID as a parameter.  The process ID can be found using any of the methods described earlier in this chapter.

The following example shows the xscreensaver process (2609) which is to be terminated.

$ pgrep xscreen
2609
$ kill 2609

Though we use pgrep to find the PID of this process here we could have also used a PID from the output of top or ps.

When there a stubborn process trapping the kill command and refusing to terminate, the -9 (SIGKILL) signal should be used to kill the process. The -9 signal cannot be trapped by a process and ignored. If the xscreensaver process did not terminate after the last kill command, the new kill command would look like the following:

$ kill -9 2609

While the kill command is typically availble to all users you will only be able to kill processes you own.  To kill processes owned by other users you will need root privileges.

Kill Processes Using a Pattern

Rather than scanning through process ID (PID) numbers, it might be easier to kill a process or group of processes by searching for a pattern in the command name field.  The pkill command is one way to accomplish this, as shown below.  pkill matches processes in the same way pgrep does.  Be very careful when using pkill as you could easily kill more than you wanted to!

Here we want to kill all processes called xscreen.  First we use pgrep to make sure we get a reasonable number of PIDs back, then we kill the process with pkill.

$ pgrep xscreen
2609
$ pkill xscreen

Again, be careful using pkill, especially as root!

Kill All Processes Owned By a Particular User

The pkill command also recognizes the ?u option to look only at a specific user's processes. By adding the -u option to the pkill command, it is possible to terminate any and all processes for the specified user. If, for example, the following command was entered by user terry, all terry?s active processes would be cancelled, and terry would be kicked off the system.

$ pkill -9 ?u terry

* Please save any work in progress before trying this!

Since you have the ability to kill any user's processes this would be a quick way to stop everything they're doing.  Be careful though, doing so may not make you any friends, if you know what I mean.

We've talked mostly about two users so far, root and you (terry in most of the examples,) but there could be more people than that on our Linux system!  Next we'll look at how to tell who's logged in.


This is an excerpt from "Easy Linux Commands" by Linux guru Jon Emmons.  You can purchase it for only $19.95 (30%-off) at this link.


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2016

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.