Created
February 2, 2018 08:50
-
-
Save road3x/58d47081aa9fdc7865683731ccff08ae to your computer and use it in GitHub Desktop.
Kill processes that are running for more than few minutes
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
#!/bin/bash | |
PROCESS_NAME="gitlab-shell key" | |
for i in `ps aux | grep "$PROCESS_NAME" | grep -v root | gawk '{print $2 "_" $10}' | sed 's/://'` | |
do | |
PROCCESSNUM=`echo $i | cut -f1 -d'_'`; | |
TIMENUM=`echo $i | cut -f2 -d'_'`; | |
if [ $TIMENUM -gt 120 ]; then | |
kill $PROCCESSNUM; | |
# echo "kill $PROCCESSNUM at "`date`; | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment