Last active
July 16, 2018 09:51
-
-
Save peterkappus/ad950d0cd501a4caae4232bc73344327 to your computer and use it in GitHub Desktop.
Jenkins shell script job to Check the diskspace on a machine (specifically, see if the /usr mount is over 60% full)
This file contains hidden or 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
# See if the /usr mount is over 60% full | |
# If so, exit with a status of 1. Otherwise, OK | |
df -h | grep "/usr" | grep -oP "\d+%" | grep -oP "\d+" | xargs -L1 -I{} bash -c 'if [ {} -ge 60 ]; then exit 1; else exit 0; fi' | |
# BONUS! | |
# remove any gz file older than 60 days which are type "file" (not directories) | |
find /path/to/logs/ -name "*.gz" -mtime +60 -type f -exec rm {} + | |
#zip any log file older than 10 days | |
find /path/to/logs/ -name "*.log" -mtime +10 -type f -exec gzip {} + |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment