Skip to content

Instantly share code, notes, and snippets.

@ststeiger
Last active October 23, 2025 17:38
Show Gist options
  • Select an option

  • Save ststeiger/610842edd15cbdba5c35dce4e72fd894 to your computer and use it in GitHub Desktop.

Select an option

Save ststeiger/610842edd15cbdba5c35dce4e72fd894 to your computer and use it in GitHub Desktop.
Kill Rider on Linux
#!/usr/bin/env bash
#
# kill_rider.sh - Kill all processes containing "rider" (case-insensitive)
#
# List matching processes first for safety, excluding this script itself
echo "🔍 Matching processes:"
ps aux | grep -i rider | grep -v grep | grep -v kill_rider.sh
# Ask for confirmation before killing
read -p "⚠️ Kill these processes? [y/N]: " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
# Find and kill them, excluding this script itself
ps aux | grep -i rider | grep -v grep | grep -v kill_rider.sh | awk '{print $2}' | xargs -r kill -9
echo "✅ Processes killed."
else
echo "❌ Aborted."
fi
OR
#!/usr/bin/env bash
#
# kill_rider.sh - Kill all processes containing "rider" (case-insensitive) without confirmation
#
# Exclude this script's PID dynamically and kill matching processes
ps aux | grep -i rider | grep -v grep | awk -v pid=$$ '$2 != pid {print $2}' | xargs -r kill -9
echo "✅ All 'rider' processes killed (except this script)."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment