Created
April 2, 2024 06:46
-
-
Save srirajk/197dde25236cd05cbe1e51ccec6862c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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