Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alcf_pbs_hooks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AIG-public
alcf_pbs_hooks
Commits
7f01135b
Commit
7f01135b
authored
3 years ago
by
William (Bill) E. Allcock
Browse files
Options
Downloads
Patches
Plain Diff
adding the node clean up script; provided by HPE, modified by me
parent
7b033389
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
clean-node.sh
+138
-0
138 additions, 0 deletions
clean-node.sh
with
138 additions
and
0 deletions
clean-node.sh
0 → 100644
+
138
−
0
View file @
7f01135b
#!/bin/bash
shopt
-s
extglob
RET
=
0
AVOIDUIDS
=
"messagebus|nobody|nscd|ntp|postfix|root|USER|dbus|nslcd|polkitd|rpc|rpcuser|munge|nvidia-persistenced|chrony|pbsdata|statd"
# Print usage banner
function
usage
()
{
echo
"Usage:
$0
[OPTION]"
echo
" -p run prologue modules"
echo
" -e run epilogue modules"
echo
" -c run cleaning modules"
}
###############################################################################
# Clean up functions
###############################################################################
function
clean_tmp
()
{
logger
"Cleaning /tmp"
find /tmp
!
-user
root
-exec
rm
-rf
{}
\;
&> /dev/null
}
function
clean_shared_mem
()
{
logger
"Cleaning shared memory"
# Clean semaphores
for
i
in
`
ipcs
-s
|
grep
-v
root |
grep
-v
pbsdata |
awk
'{print $2}'
|
grep
^[0-9]
`
do
ipcrm
-s
$i
&> /dev/null
done
# Clean shared mem
for
i
in
`
ipcs
-m
|
grep
-v
root |
grep
-v
pbsdata |
awk
'{print $2}'
|
grep
^[0-9]
`
do
ipcrm
-m
$i
&> /dev/null
done
}
function
clean_user_procs
()
{
logger
"Cleaning stray processes"
-semaphores
for
i
in
`
ps
--no-headers
-eo
euser | egrep
-v
"
${
AVOIDUIDS
}
"
|
sort
|
uniq
`
do
logger
"Killing
$i
processes..."
pkill
-9
-u
$i
&>/dev/null
done
}
function
clean_dev_shm
()
{
cwd
=
$PWD
cd
/dev/shm
rm
-rf
-v
!(
"lldpad.state"
)
&>/dev/null
cd
$cwd
}
function
clean_memory_cache
()
{
logger
"Flushing caches"
# sync; echo 1 > /proc/sys/vm/drop_caches
# sync; echo 2 > /proc/sys/vm/drop_caches
sync
;
echo
3
>
/proc/sys/vm/drop_caches
}
function
print_job_start
()
{
logger
-t
PBSJOBSTART_
$1
"PBS Job
$1
started by
$2
"
}
function
print_job_end
()
{
logger
-t
PBSJOBEND_
$1
"PBS Job
$1
completed by
$2
"
}
###############################################################################
# Main Script
###############################################################################
# Verify and process cmd line options
if
[
$#
-lt
1
]
then
usage
exit
1
fi
case
$1
in
-p
)
logger
-t
PROLOGUE_CLEANUP_START_
$2
"Starting prologue cleanup"
# Add the user to the list of user procs to avoid
AVOIDUIDS+
=
"|
$3
"
clean_tmp
clean_shared_mem
clean_user_procs
clean_dev_shm
clean_memory_cache
logger
-t
PROLOGUE_CLEANUP_END_
$2
"Completed prologue cleanup"
print_job_start
"
$2
"
"
$3
"
;;
-e
)
logger
-t
EPILOGUE_CLEANUP_START_
$2
"Starting epilogue cleanup"
print_job_end
"
$2
"
"
$3
"
clean_tmp
clean_shared_mem
clean_user_procs
clean_dev_shm
clean_memory_cache
logger
-t
EPILOGUE_CLEANUP_END_
$2
"Completed epilogue cleanup"
;;
-c
)
echo
"Running epilogue modules..."
clean_tmp
clean_shared_mem
clean_user_procs
clean_dev_shm
clean_memory_cache
logger
-t
EPILOGUE_CLEANUP_END
"The epilogue cleanup has completed"
;;
*
)
usage
RET
=
1
;;
esac
exit
$RET
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