{"id":3104,"date":"2014-01-14T19:08:25","date_gmt":"2014-01-14T19:08:25","guid":{"rendered":"http:\/\/blog.shineservers.com\/?p=2405"},"modified":"2014-01-14T19:08:25","modified_gmt":"2014-01-14T19:08:25","slug":"manage-processes-killall-kill","status":"publish","type":"post","link":"https:\/\/www.shineservers.com\/2014\/01\/14\/manage-processes-killall-kill\/","title":{"rendered":"Manage Processes with killall and kill"},"content":{"rendered":"<p><tt>killall<\/tt>\u00a0is a tool for ending running processes on your system based on name. In contrast,\u00a0<tt>kill<\/tt>\u00a0terminates processes based on process ID number or &#8220;PID.&#8221;\u00a0<tt>kill<\/tt>\u00a0and\u00a0<tt>killall<\/tt>can also send specific system signals to processes. Use\u00a0<tt>killall<\/tt>\u00a0and\u00a0<tt>kill<\/tt>\u00a0in conjunction with tools including\u00a0<tt>ps<\/tt>\u00a0to manage processes and end processes that have become stuck or unresponsive when necessary.<\/p>\n<div id=\"sph_usage\">\n<h1>Usage<\/h1>\n<div id=\"sph_killall\">\n<h2>killall<\/h2>\n<p>The\u00a0<tt>killall<\/tt>\u00a0command takes the following form:<\/p>\n<pre>killall [process name]<\/pre>\n<p>Replace &#8220;<tt>[process name]<\/tt>&#8221; with the name of any process that you wish to terminate.\u00a0<tt>killall<\/tt>\u00a0will terminate all programs that match the name specified. Without arguments,<tt>killall<\/tt>\u00a0sends &#8220;<tt>SIGTERM<\/tt>&#8220;, or signal number 15, which terminates running processes that match the name specified. You may specify a different signal using the &#8220;<tt>-s<\/tt>&#8221; option as follows:<\/p>\n<pre>killall -s 9 [process name]<\/pre>\n<p>This sends the &#8220;<tt>SIGKILL<\/tt>&#8221; signal which is more successful at killing some particularly unruly processes. You may also specify signals in one of the following formats:<\/p>\n<pre>killall -KILL [process name]\nkillall -SIGKILL [process name]\nkillall -9 [process name]<\/pre>\n<p>The above group of commands are equivalent.<\/p>\n<\/div>\n<div id=\"sph_kill\">\n<h2>kill<\/h2>\n<p>The\u00a0<tt>kill<\/tt>\u00a0command terminates individual processes as specified by their process ID numbers or &#8220;PIDs.&#8221; Commands take the following form:<\/p>\n<pre>kill [PID]<\/pre>\n<p>This sends &#8220;<tt>SIGTERM<\/tt>&#8221; to the PID specified. You may specify multiple PIDs on the command line to terminate processes with &#8220;<tt>kill<\/tt>&#8220;. You may also send alternate system signals with kill. The following examples all send the &#8220;<tt>SIGKILL<\/tt>&#8221; signal to the PID specified:<\/p>\n<pre>kill -s KILL [PID]\nkill -KILL [PID]<\/pre>\n<\/div>\n<div id=\"sph_system-signals\">\n<h2>System Signals<\/h2>\n<p>You may use\u00a0<tt>kill<\/tt>\u00a0and\u00a0<tt>killall<\/tt>\u00a0to send any of the following signals.<\/p>\n<ol>\n<li><tt>SIGHUP<\/tt><\/li>\n<li><tt>SIGINT<\/tt><\/li>\n<li><tt>SIGQUIT<\/tt><\/li>\n<li><tt>SIGILL<\/tt><\/li>\n<li><tt>SIGTRAP<\/tt><\/li>\n<li><tt>SIGABRT<\/tt><\/li>\n<li><tt>SIGIOT<\/tt><\/li>\n<li><tt>SIGFPE<\/tt><\/li>\n<li><tt>SIGKILL<\/tt><\/li>\n<li><tt>SIGUSR1<\/tt><\/li>\n<li><tt>SIGSEGV<\/tt><\/li>\n<li><tt>SIGUSR2<\/tt><\/li>\n<li><tt>SIGPIPE<\/tt><\/li>\n<li><tt>SIGALRM<\/tt><\/li>\n<li><tt>SIGTERM<\/tt><\/li>\n<li><tt>SIGSTKFLT<\/tt><\/li>\n<li><tt>SIGCHLD<\/tt><\/li>\n<li><tt>SIGCONT<\/tt><\/li>\n<li><tt>SIGSTOP<\/tt><\/li>\n<li><tt>SIGSTP<\/tt><\/li>\n<li><tt>SIGTTIN<\/tt><\/li>\n<li><tt>SIGTTOU<\/tt><\/li>\n<li><tt>SIGURG<\/tt><\/li>\n<li><tt>SIGXCPU<\/tt><\/li>\n<li><tt>SIGXFSZ<\/tt><\/li>\n<li><tt>SIGVTALRM<\/tt><\/li>\n<li><tt>SIGPROF<\/tt><\/li>\n<li><tt>SIGWINCH<\/tt><\/li>\n<li><tt>SIGIO<\/tt>\u00a0and\u00a0<tt>SIGPOLL<\/tt><\/li>\n<li><tt>SIGPWR<\/tt><\/li>\n<li><tt>SIGSYS<\/tt><\/li>\n<\/ol>\n<p>Issue one of the following commands to get a list of all of the available signals:<\/p>\n<pre>kill -l\nkillall -l<\/pre>\n<p>If you need to convert a signal name into a signal number, or a signal number into a signal name consider the following examples:<\/p>\n<pre>$ kill -l 9\nKILL$ kill -l kill\n9<\/pre>\n<\/div>\n<\/div>\n<div id=\"sph_finding-running-processes\">\n<h1>Finding Running Processes<\/h1>\n<p>You may use a utility like\u00a0<cite>htop &lt;\/using-linux\/administration-basics#monitor_processes__memory__and_cpu_usage_with_htop&gt; or &#8220;top`<\/cite>\u00a0to view a real time list of process and their consumption of system resources. You may also use the\u00a0<tt>ps<\/tt>\u00a0command to view processes that are currently running and their PIDs.<\/p>\n<pre>$ ps aux | grep \"emacs\"\nsquire  3896  0.0  2.2  56600 44468 ?        Ss   Sep30   4:29 emacs\nsquire 22843  0.0  0.0   3900   840 pts\/11   S+   08:49   0:00 grep emacs<\/pre>\n<p>This command filters the list of all processes that are currently running for the string &#8220;<tt>emacs<\/tt>&#8221; using\u00a0grep. The number listed in the second column is the PID, which is\u00a0<tt>3896<\/tt>\u00a0in the case of the &#8220;<tt>emacs<\/tt>&#8221; process. The\u00a0<tt>grep<\/tt>\u00a0process will always match itself for a simple search, as in the second result. To view a hierarchical tree of all running processes, issue the following command:<\/p>\n<pre>ps auxf<\/pre>\n<p>Once you have obtained the PID or process name, use\u00a0<tt>killall<\/tt>\u00a0or\u00a0<tt>kill<\/tt>\u00a0to terminate the process as above.<\/p>\n<\/div>\n<div id=\"sph_verifying-process-termination\">\n<h1>Verifying Process Termination<\/h1>\n<p>The &#8220;<tt>-w<\/tt>&#8221; option to the\u00a0<tt>killall<\/tt>\u00a0command causes\u00a0<tt>killall<\/tt>\u00a0to wait until the process terminates before exiting. Consider the following command:<\/p>\n<pre>killall -w irssi<\/pre>\n<p>This command issues the &#8220;<tt>SIGTERM<\/tt>&#8221; system signal to the process with a name that matches &#8220;<tt>irssi<\/tt>&#8220;.&#8220;killall&#8220; will wait until the matched processes have ended. If no process matches the name specified,\u00a0<tt>killall<\/tt>\u00a0returns an error message, as below:<\/p>\n<pre>$ killall -w irssi\nirssi: no process found<\/pre>\n<p>&nbsp;<\/p>\n<\/div>\n<h3 class=\"zemanta-related-title\" style=\"margin: 0 0 10px 0; padding: 0; clear: both;\">Related articles across the web<\/h3>\n<ul class=\"zemanta-article-ul zemanta-article-ul-image\" style=\"margin: 0; padding: 0; overflow: hidden;\">\n<li class=\"zemanta-article-ul-li-image zemanta-article-ul-li\" style=\"padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 104px; font-size: 12px; margin: 0 5px 10px 0;\"><a style=\"padding: 2px; display: block; text-decoration: none;\" href=\"http:\/\/jvns.ca\/blog\/2013\/12\/22\/fun-with-strace\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" style=\"border-radius: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); padding: 0; margin: 0; border: 0; display: block; width: 100px; max-width: 100%;\" alt=\"\" src=\"http:\/\/i.zemanta.com\/noimg_4_150_150.jpg\" \/><\/a><a style=\"display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;\" href=\"http:\/\/jvns.ca\/blog\/2013\/12\/22\/fun-with-strace\/\" target=\"_blank\" rel=\"noopener noreferrer\">Understanding how killall works using strace<\/a><\/li>\n<li class=\"zemanta-article-ul-li-image zemanta-article-ul-li\" style=\"padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 104px; font-size: 12px; margin: 0 5px 10px 0;\"><a style=\"padding: 2px; display: block; text-decoration: none;\" href=\"http:\/\/blog.shineservers.com\/install-vnc-server-centos\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" style=\"border-radius: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); padding: 0; margin: 0; border: 0; display: block; width: 100px; max-width: 100%;\" alt=\"\" src=\"http:\/\/i.zemanta.com\/232740948_150_150.jpg\" \/><\/a><a style=\"display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;\" href=\"http:\/\/blog.shineservers.com\/install-vnc-server-centos\/\" target=\"_blank\" rel=\"noopener noreferrer\">How To Install VNC Server On CentOS<\/a><\/li>\n<li class=\"zemanta-article-ul-li-image zemanta-article-ul-li\" style=\"padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 104px; font-size: 12px; margin: 0 5px 10px 0;\"><a style=\"padding: 2px; display: block; text-decoration: none;\" href=\"http:\/\/blog.shineservers.com\/iredmail-build-full-featured-mail-server-centos-6-postfix-dovecot-postgresql\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" style=\"border-radius: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); padding: 0; margin: 0; border: 0; display: block; width: 100px; max-width: 100%;\" alt=\"\" src=\"http:\/\/i.zemanta.com\/232740915_150_150.jpg\" \/><\/a><a style=\"display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;\" href=\"http:\/\/blog.shineservers.com\/iredmail-build-full-featured-mail-server-centos-6-postfix-dovecot-postgresql\/\" target=\"_blank\" rel=\"noopener noreferrer\">iRedMail: Build A Full-Featured Mail Server On CentOS 6 With Postfix, Dovecot, PostgreSQL<\/a><\/li>\n<li class=\"zemanta-article-ul-li-image zemanta-article-ul-li\" style=\"padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 104px; font-size: 12px; margin: 0 5px 10px 0;\"><a style=\"padding: 2px; display: block; text-decoration: none;\" href=\"http:\/\/blog.shineservers.com\/setup-transmission-ubuntu\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" style=\"border-radius: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); padding: 0; margin: 0; border: 0; display: block; width: 100px; max-width: 100%;\" alt=\"\" src=\"http:\/\/i.zemanta.com\/232740930_150_150.jpg\" \/><\/a><a style=\"display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;\" href=\"http:\/\/blog.shineservers.com\/setup-transmission-ubuntu\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to Setup Transmission in a Ubuntu<\/a><\/li>\n<li class=\"zemanta-article-ul-li-image zemanta-article-ul-li\" style=\"padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 104px; font-size: 12px; margin: 0 5px 10px 0;\"><a style=\"padding: 2px; display: block; text-decoration: none;\" href=\"http:\/\/blog.shineservers.com\/create-ssl-certificate-apache-centos-6\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" style=\"border-radius: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); padding: 0; margin: 0; border: 0; display: block; width: 100px; max-width: 100%;\" alt=\"\" src=\"http:\/\/i.zemanta.com\/232740922_150_150.jpg\" \/><\/a><a style=\"display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;\" href=\"http:\/\/blog.shineservers.com\/create-ssl-certificate-apache-centos-6\/\" target=\"_blank\" rel=\"noopener noreferrer\">How To Create a SSL Certificate on Apache for CentOS 6<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>killall\u00a0is a tool for ending running processes on your system based on name. In contrast,\u00a0kill\u00a0terminates processes based on process ID number or &#8220;PID.&#8221;\u00a0kill\u00a0and\u00a0killallcan also send specific system signals to processes. Use\u00a0killall\u00a0and\u00a0kill\u00a0in conjunction with tools including\u00a0ps\u00a0to manage processes and end processes that have become stuck or unresponsive when necessary. Usage killall The\u00a0killall\u00a0command takes the following form: [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[60],"tags":[],"class_list":["post-3104","post","type-post","status-publish","format-standard","hentry","category-linux"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/3104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/comments?post=3104"}],"version-history":[{"count":0,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/3104\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/media?parent=3104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/categories?post=3104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/tags?post=3104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}