Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/help/en/bash/kill.html
blob: 904ffa4d0e7d3b100efbc818d3df7f8958fc7cbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<link rel="STYLESHEET" href="../term_tools/main.css" type="text/css">
<title>kill MAN Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body><!-- #BeginLibraryItem "/Library/head_bash.lbi" --><div id="nav-menu">
<ul>
<li><a class="rl" href="../term_tools/index.html"><img src="../term_tools/images/ss64.gif" title="Home" alt="Home"></a></li>
<li><a class="rl" href="../term_tools/bash"><img src="../term_tools/images/bash-l.gif" title="bash" alt="bash"></a></li>
<li><!-- Search Google -->
<form action="http://www.google.com/search" method="get" style="margin:0px;padding:0px;">
<div align="right">
<input name="q" type="text" class="body" size="25">
<input class="submit" type="submit" value="Search">
<input type="hidden" name="q" value="site:ss64.com/bash/">
</div>
</form></li>
<li><a class="rr" href="syntax.html"><img src="../term_tools/images/syntax-r.gif" title="Bash Syntax"></a></li>
</ul>
</div> <!-- #EndLibraryItem --><h1> kill</h1> 
<p>Stop a process from running, either via a signal or forced termination.</p>
<pre>Syntax
      kill [-s <var>sigspec</var>] [-n <var>signum</var>] [-<var>sigspec</var>] <var>jobspec</var> or <var>pid</var>
      kill -l [<var>exit_status</var>]
      kill -l [<var>sigspec</var>]

Key
   -l   List the signal names
   -s   Send a specific signal
   -n   Send a specific signal number</pre>
<p>Send a signal specified by <var>sigspec</var> or <var>signum</var> 
  to the process named by job specification <var>jobspec</var> or process ID <var>pid</var>. 
  <var><br>
  <br>
  sigspec</var> is either a case-insensitive signal name such as <code>SIGINT</code> (with or without 
  the <code>SIG</code> prefix) or a signal number; <var>signum</var> is a signal 
  number.<br>
  <br>
  If <var>sigspec</var> is not present, <code>SIGTERM</code> 
  is used (Terminate). <br>
  <br>
  If any arguments are supplied when <samp>`-l'</samp> is given, the names of 
  the signals corresponding to the arguments are listed, and the return status 
  is zero. <var>exit_status</var> is a number specifying a signal number or the 
  exit status of a process terminated by a signal.<br>
  <br>
  The return status is true if at least one signal was successfully sent, or false 
if an error occurs or an invalid option is encountered.</p>
<p><b>Examples</b></p>
<p>List the running process</p>
<pre>$ <b>ps</b>
PID TTY TIME CMD
1293 pts/5 00:00:00 MyProgram
</pre>
<p>Then Kill it</p>
<pre>$ <b>kill 1293</b>
[2]+ Terminated MyProgram
</pre>
<p><b><i>  </i></b>To run a command and then kill it after 5 seconds:</p>
<p class="code"> <span class="code">$ my_command &amp; sleep 5 <br>
</span> $ kill -0 $! &amp;&amp; kill $!</p>
<p>kill is a bash built in command: <span class="code"> $ help kill </span></p>
<p><i>&quot;Whom the gods love dies young&quot; - Menander 300 BC </i><br>
  <br>
<b> Related</b>:</p>
<p>ctrl+z  	- Suspend a program<br>
ctrl+c - Interrupt a program<br>
  <a href="ps.html">ps</a> - List running processes (returns PID)<br>
  jobs - List your own processes (returns Job No.)<br>
  <a href="bg.html">bg</a> - Put a process in the background<br>
  <a href="fg.html">fg</a> - Put a process in the foreground<br>
killall - kill processes by name <br>
<a href="pkill.html">pkill</a> - Stop  processes from running<br>
Windows equivalent command: <a href="../term_tools/nt/pskill.html">pskill</a>- Stop a process from running</p>
<!-- #BeginLibraryItem "/Library/foot_bash.lbi" --><p align="left"><script type="text/javascript"><!--
google_ad_client = "pub-6140977852749469";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_type = "text_image";
google_ad_channel ="1984328893";
google_color_border = "CCCCCC";
google_color_bg = "CCCCCC";
google_color_link = "000000";
google_color_text = "333333";
google_color_url = "0000FF";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br>
</p>
<div align="center"><hr size="1">
  <p id="top"><a href="#"><img src="../term_tools/images/top-4.gif" width="47" height="53" border="0" alt="Back to the Top" title="Back to the Top"></a></p>
  <p class="tagline">&copy; Copyright <a href="http://ss64.com/">SS64.com</a> 1999-2010<br>
Some rights reserved<br>
</p>
</div><!-- #EndLibraryItem --></body>
</html>