-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
*.sh text eol=lf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# Killing NGINX process as user provided | ||
|
||
if [ -z "$USER" ]; then | ||
echo "\$USER is not provided" | ||
exit 1 | ||
fi | ||
|
||
if [ "$USER" == "root" ]; then | ||
echo "Don't call this on root!" | ||
exit 1 | ||
fi | ||
|
||
# Get the list of processes for the user | ||
user_procs=$(ps -u $USER --forest -o pid=,comm=) | ||
|
||
# Loop through each process | ||
while read -r pid comm; do | ||
# Skip if the command is subcommand or essential features | ||
if [[ "$comm" =~ ^(\\|\|).* || "$comm" == "sh" || "$comm" == "bash" || "$comm" == "docker" || "$comm" == "systemd" ]]; then | ||
continue | ||
fi | ||
|
||
# Kill the process | ||
echo "Killing process $pid ($comm)" | ||
pkill -P $pid | ||
kill -9 $pid | ||
|
||
done <<< "$user_procs" | ||
|