Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rabbitmq_agents
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Wiki
Code
Merge requests
8
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rc
rabbitmq_agents
Commits
19e92f94
Commit
19e92f94
authored
1 month ago
by
Dylan Wheeler
Browse files
Options
Downloads
Patches
Plain Diff
feat: updating script to be more robust and adding in specific username flag
parent
f5e9b3aa
No related branches found
No related tags found
1 merge request
!159
FEAT: adding simple script to kill all of a user's currently running processes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/kill_user_process.sh
+23
-14
23 additions, 14 deletions
scripts/kill_user_process.sh
with
23 additions
and
14 deletions
scripts/kill_user_process.sh
+
23
−
14
View file @
19e92f94
#!/bin/bash
username
=
"
$1
"
username
=
""
force
=
false
while
getopts
':u:k'
uname
;
do
case
$uname
in
u
)
username
=
${
OPTARG
}
;;
k
)
force
=
true
;;
esac
done
usage
()
{
echo
"Usage:
$0
USERNAME to run graceful shutdown of processes"
echo
"Usage:
$0
USERNAME -k to run forced shutdown of processes"
echo
"Usage:
$0
-u
USERNAME to run graceful shutdown of processes"
echo
"Usage:
$0
-u
USERNAME -k to run forced shutdown of processes"
}
if
[[
"
$EUID
"
-ne
0
]]
;
then
...
...
@@ -12,25 +24,22 @@ if [[ "$EUID" -ne 0 ]]; then
exit
1
fi
if
[
-z
"
$username
"
]
;
then
usage
exit
1
exit
1
fi
userId
=
`
id
-u
$
1
`
userId
=
$(
id
-u
$
username
)
if
[
"
$username
"
=
"root"
]
;
then
echo
"Username cannot be root"
exit
1
echo
"Username cannot be root"
exit
1
fi
if
[
-z
$2
]
;
then
echo
"Performing SIGTERM on processes belonging to
$username
"
pkill
-u
$userId
elif
[
$2
=
"-k"
]
;
then
if
[
"
$force
"
=
true
]
;
then
echo
"Performing SIGKILL on processes belonging to
$username
"
pkill
-9
-u
$userId
else
echo
"Performing SIGTERM on processes belonging to
$username
"
pkill
-u
$userId
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment