From b9db77ff3ce8856d1e95280a102920045cc10ffe Mon Sep 17 00:00:00 2001 From: pdiogoantunes Date: Tue, 2 May 2017 18:02:26 +0200 Subject: [PATCH] lister plus de fils --- TipsShell.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TipsShell.md b/TipsShell.md index 86906ac9..c6a58d63 100644 --- a/TipsShell.md +++ b/TipsShell.md @@ -318,4 +318,10 @@ Se baser seulement par rapport aux utilisateurs ayant créés dernièrement ces ~~~{.bash} $ SEUIL=100; watch -n 5 -d "ps -e -o etimes=,user | sort -n | awk '{if (\$1<$SEUIL) print \$2 }' | sort | uniq -c | sort -n" +~~~ + +## Lister les process ayant le plus de fils + +~~~{.bash} +(total_procs=0; for foo in $(ps -e -o ppid | sed '1d' | sort -n | uniq -c | sort -n | awk '{ print $1 ":" $2 }'); do val=$(echo $foo | cut -d: -f1); total_procs=$((total_procs+val)); pid=$(echo $foo | cut -d: -f2); (( pid != 0 )) && { echo -n $val ') '; ps -p $pid -o pid,cmd | tail -n1; }; done; echo Total = $total_procs) | tail ~~~ \ No newline at end of file