0 Shares 3395 Views 1 Comments
00:00:00
02 May

Killing A Process On CentOS, Ubuntu And Other Linux Distributions

Oliver Krautscheid Sep 30, 2014
0 3396 1

As a webmaster administrating a server you may often run into errors with file and process locks – in that case it is handy to know how to kill a process on CentOS and other Linux distributions.

Finding The Process

1. Open up putty or whatever app you use to connect to your SSH shell

2. If you want to kill a yum process for example, let’s first get the process id, to do that we don’t have to know much:

ps aux | grep yum
ps aux | grep process
ps aux | grep apt-get
ps aux | grep named

“ps aux” fetches all processess currently running on CentOS and grep is a tool to locate text/strings. Yum is the default package installer on CentOS (the equivalent on Ubuntu is apt-get install)

3. Alright we will get something similar to this, where we see the process ID of all yum process that are currently running

Run Ps Aux To Fetch Process List.png

Syntax

4. The syntax to kill a process on CentOS is fairly simple and straight-forward:

kill SIGNAL processID 

(where processID needs to be replaced with the actual ID and SIGNAL is an OPTIONAL parameter)

There are 3 SIGNALS:

  1. -1 (process hangs, reload kill)
  2. -9 (not recommend, force kill)
  3. -15 (default, safe kill)

Always try the default first which looks like kill ProcessID

If you want to know more about SIGNALS, read this Wiki Article

Killing The Process: Example

Default, safe kill

kill 25632

Force kill:

kill -9 25632

Hangup:

kill -1 25632

Yum Processes: Force Kill Required By Root

If some of your YUM processes get stuck, it is OFTEN required to force kill the process, everything else won’t work

Root User Force Kills Process.png

In my case, I had to force kill the process using the SIGNAL -9 and voilĂ  the process was killed successfully. In some cases, you may need to be logged in as a root user to kill the process. If you are not logged in as a root user you can’t kill processes initiated by other users. You also need root privileges to kill a system process

Questions? Let us know in the comments

About Us

Webmaster .Net is your all-in-one resource for blogging tips, system administration guides, industry news and a growing community of webmasters.

Can't find something or want to tip us?Contact@webmaster.net

Bulls and Bears
  • http://about.me/oliver.krautscheid Oliver Krautscheid

    As mentioned, force kills can sometimes mess up processes completely. For example I would not force kill a mysql process simply because it is not responding!

    The mysql lock file sometimes disappears and then you cant use the service command to restart. In that case it is a better idea to use actual service commands like “mysqladmin” to shut down the service

    Also when copying mission-critical files I would not force-kill that process.

Webmaster Tutorials, Wordpress
0 shares661 views

WordPress SQL Query: Select And Delete Posts Between Two Dates

Oliver Krautscheid - Apr 08, 2017

If you are wondering how to delete posts for a certain date, you will need to know how Wordpress stores…

Advertising and Ad Networks, Copywriting
0 shares806 views

15 Tips For Increasing Facebook Ads CTR – Full Guide [2017 Update]

Cam Connor - Mar 30, 2017

In this article, we'll talk a lot about how you can write quality text ads on Facebook Ads to get…

Webmaster Tutorials
0 shares1484 views

10 Steps To Configure Nginx For WordPress, Drop Varnish And Cut Your CPU Load By 50%

Oliver Krautscheid - Oct 10, 2016

Are you using Varnish on your Wordpress blog? Possibly the Varnish script by Unixy? Great! Get rid off it. Here's…

Follow Us And get latest news

© 2016 Webmaster.Net - Property of Peakstone Media Ltd. - All rights reserved. | Privacy Policy | DMCA | Contact Us | Advertise