← Back to Bash Course | Chapter 10: Text Processing Tools | Lesson 6 of 12

kill कमांड

kill एक runner के shoulder पर tap करके उसे nicely रुकने को कहने जैसा है। अगर वे नहीं सुनते, stronger version उन्हें track से सीधे yank कर देता है।

In this page:

  1. kill
Syntax
bash
kill [-signal] process_id

kill

kill एक process को एक signal भेजता है, सबसे commonly SIGTERM (default) इसे gracefully terminate होने को कहने के लिए, या SIGKILL (kill -9) इसे immediately रुकने के लिए force करने के लिए।

आप एक process को इसके PID से target करते हैं। Scripts kill उपयोग करती हैं उन background jobs को रोकने के लिए जो उन्होंने शुरू की थीं, जैसे testing के लिए spin up किया एक server process।

Warning: kill -9 (SIGKILL) को process catch या ignore नहीं कर सकता, इसलिए exit करने से पहले इसे clean up करने का कभी chance नहीं मिलता।

उदाहरण: kill

bash
#!/bin/bash
sleep 30 &
pid=$!
echo "Started process $pid"

kill "$pid"
echo "Sent termination signal to $pid"
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. पहले kill -9 उपयोग करना, जो process को clean up करने से रोकता है; पहले plain kill try करें।
  2. एक outdated value से गलत PID को kill करना।
  3. यह भूल जाना कि kill सिर्फ एक signal भेजता है, जिसे process handle या ignore कर सकता है।
🔒

Chapter Quiz — Complete all 12 topics to unlock

0/12 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.