Linux / Bash
Beginner
1 min read
Signals, kill, and Process Priorities
Example
# ---- Sending signals with kill ----
# Gracefully terminate a process (SIGTERM = 15)
kill 1234
kill -15 1234
kill -SIGTERM 1234
# Force kill (SIGKILL = 9) — cannot be caught or ignored
kill -9 1234
kill -SIGKILL 1234
# Reload configuration (SIGHUP = 1)
kill -HUP $(cat /var/run/nginx.pid)
# Send signal by name
kill -l # List all signal names
# ---- killall and pkill ----
# Kill all processes named 'python3'
killall python3
# Kill with SIGKILL
killall -9 runaway_script
# Kill processes matching a pattern
pkill -f "python3 myscript.py"
# Kill processes owned by a specific user
pkill -u bob
# ---- Process priority (nice / renice) ----
# Start a command at low priority (nice 10)
nice -n 10 tar -czf big_archive.tar.gz /data/
# Start at highest nice (least CPU impact)
nice -n 19 find / -name "*.log" -exec gzip {} \;
# Renice a running process (requires sudo for -20 to -1)
renice -n 5 -p 1234 # Set nice to 5 for PID 1234
sudo renice -n -5 -p 1234 # Increase priority (needs root)
# Renice all processes of a user
renice -n 10 -u alice
Related Resources
Linux / Bash Reference
Complete tag & property list
Linux / Bash How-To Guides
Step-by-step practical guides
Linux / Bash Exercises
Practice what you've learned
More in Linux / Bash