[Qa-jenkins-scm] [jenkins.debian.net] 01/01: reproducible: only kill parentless processes if they are older than a day

Holger Levsen holger at moszumanska.debian.org
Fri Mar 20 12:22:01 UTC 2015


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit 541b1d3ecba24f7031bbcbb5f32575210cd38ac8
Author: Holger Levsen <holger at layer-acht.org>
Date:   Fri Mar 20 13:19:52 2015 +0100

    reproducible: only kill parentless processes if they are older than a day
---
 bin/reproducible_maintainance.sh | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/bin/reproducible_maintainance.sh b/bin/reproducible_maintainance.sh
index a473da1..d0026e4 100755
--- a/bin/reproducible_maintainance.sh
+++ b/bin/reproducible_maintainance.sh
@@ -113,19 +113,25 @@ RESULT=$(mktemp)
 PBUIDS="1234 1111 2222"
 ps axo pid,user,size,pcpu,cmd > $HAYSTACK
 for i in $PBUIDS ; do
-	for ZOMBIE in $(pgrep -u $i -P 1 || true) ; do
+	for PROCESS in $(pgrep -u $i -P 1 || true) ; do
 		# faked-sysv comes and goes...
-		grep ^$ZOMBIE $HAYSTACK | grep -v faked-sysv >> $RESULT 2> /dev/null || true
+		grep ^$PROCESS $HAYSTACK | grep -v faked-sysv >> $RESULT 2> /dev/null || true
 	done
 done
 if [ -s $RESULT ] ; then
 	echo
-	echo "Warning: processes found which should not be there, killing them now:"
+	echo "Warning: processes found which should not be there, maybe killing them now:"
 	cat $RESULT
 	echo
-	ZOMBIES=$(cat $RESULT | cut -d " " -f1 | xargs echo)
-	sudo kill -9 $(echo $ZOMBIES) 2>&1
-	echo "'kill -9 $(echo $ZOMBIES)' done."
+	for PROCESS in $(cat $RESULT | cut -d " " -f1 | xargs echo) ; do
+		AGE=$(ps -p $PROCESS -o etimes= || echo 0)
+		if [ $AGE -gt 86400 ] ; then
+			sudo kill -9 $PROCESS 2>&1
+			echo "'kill -9 $PROCESS' done."
+		else
+			echo "Did not kill $PROCESS as it is only $AGE seconds old."
+		fi
+	done
 	echo
 	DIRTY=true
 fi

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list