-
-
Notifications
You must be signed in to change notification settings - Fork 1
Linux wait Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to wait on Linux, covering Arch Linux, CachyOS, and other distributions including waiting for processes, job synchronization, and process coordination.
wait waits for background jobs to complete.
Uses:
- Wait for jobs: Wait for job completion
- Synchronization: Synchronize processes
- Script coordination: Coordinate in scripts
- Process management: Manage process completion
Why it matters:
- Synchronization: Wait for processes
- Scripts: Coordinate script execution
- Job control: Manage job completion
Basic usage:
# Wait for all jobs
wait
# Waits for all background jobsJob number:
# Wait for specific job
wait %1
# Or
wait 1
# %1 = job number 1Wait for several:
# Wait for multiple jobs
wait %1 %2 %3
# Waits for all specified jobsGet exit code:
# Wait and get exit status
wait %1
echo "Exit code: $?"Use in scripts:
#!/bin/bash
command1 &
PID1=$!
command2 &
PID2=$!
# Wait for both
wait $PID1 $PID2
echo "Both commands completed"Check jobs:
# List jobs first
jobs
# Verify job number existsThis guide covered wait usage, job synchronization, and process coordination for Arch Linux, CachyOS, and other distributions.
- jobs Guide - List jobs
- Bash Scripting Guide - Scripting
- Process Management - Process management
-
wait Documentation:
man wait
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.