blob: 1826561e3cb733fb18a179dac5e0a1fbc17603c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/bin/sh
set -e
d=$(mktemp -d)
trap "cd /; rm -r '$d'" EXIT
cd "$d"
web_content_pids()
{
top -w512 -bn1 -o '%MEM' | sed -e '1,/^$/d' | {
while read line
do set -- $line
[ "${12} ${13}" = "Web Content" ] || continue
echo $1
done
}
}
lesser_tabs()
{
web_content_pids > pids
if [ $(wc -l < pids) -gt 1 ]
then
sed 1d < pids | tac
fi
}
FIRST=y
for tab in $(lesser_tabs)
do
if [ "$FIRST" ]
then
FIRST=
ps $tab
(set -x
kill "$tab")
fi
ps $tab
done
|