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

wait कमांड

wait finish line पर खड़े रहकर आपके उन friends का इंतज़ार करने जैसा है जो background में भाग गए थे। Script रुक जाता है जब तक वे सभी वापस न आ जाएं।

In this page:

  1. wait
Syntax
bash
command &
wait [process_id]

wait

wait एक script को रोकता है जब तक एक background job खत्म न हो, या अगर बिना किसी argument के call किया जाए तो जब तक सभी background jobs खत्म न हों। wait $pid एक specific job के लिए wait करता है और इसका exit status capture करता है।

मल्टिपल background tasks को आगे बढ़ने से पहले coordinate करने के लिए यह essential है।

Note: wait को बिना किसी argument के call करें तब तक रुकने के लिए जब तक script ने start किए हर *एक* background job complete न हो जाए।

उदाहरण: wait

bash
#!/bin/bash
sleep 1 &
sleep 1 &

echo "Waiting for all background jobs..."
wait
echo "All background jobs finished"
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. wait को बिना PID के call करना और एक specific job का exit status expect करना।
  2. Command पर & भूल जाना, इसलिए wait करने के लिए कुछ नहीं है।
  3. उस PID के लिए wait करना जो current shell का child नहीं है।
🔒

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.