Skip to content

Instantly share code, notes, and snippets.

@srirajk
Created April 2, 2024 06:46
Show Gist options
  • Save srirajk/197dde25236cd05cbe1e51ccec6862c7 to your computer and use it in GitHub Desktop.
Save srirajk/197dde25236cd05cbe1e51ccec6862c7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Find processes matching the criteria and filter out the PID
pids=$(ps -ef | grep "uid123" | grep "java -jar" | grep "spark-submit" | grep -v grep | awk '{print $2}')
# Check if any matching processes were found
if [ -n "$pids" ]; then
echo "Matching processes found: $pids"
# Kill the processes
echo "Killing matching processes..."
kill $pids
echo "Processes killed."
else
echo "No matching processes found."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment