diff options
Diffstat (limited to 'fireslay')
-rwxr-xr-x | fireslay | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/fireslay b/fireslay new file mode 100755 index 0000000..1826561 --- /dev/null +++ b/fireslay | |||
@@ -0,0 +1,38 @@ | |||
1 | #!/bin/sh | ||
2 | set -e | ||
3 | d=$(mktemp -d) | ||
4 | trap "cd /; rm -r '$d'" EXIT | ||
5 | cd "$d" | ||
6 | |||
7 | web_content_pids() | ||
8 | { | ||
9 | top -w512 -bn1 -o '%MEM' | sed -e '1,/^$/d' | { | ||
10 | while read line | ||
11 | do set -- $line | ||
12 | [ "${12} ${13}" = "Web Content" ] || continue | ||
13 | echo $1 | ||
14 | done | ||
15 | } | ||
16 | } | ||
17 | |||
18 | lesser_tabs() | ||
19 | { | ||
20 | web_content_pids > pids | ||
21 | if [ $(wc -l < pids) -gt 1 ] | ||
22 | then | ||
23 | sed 1d < pids | tac | ||
24 | fi | ||
25 | } | ||
26 | |||
27 | FIRST=y | ||
28 | for tab in $(lesser_tabs) | ||
29 | do | ||
30 | if [ "$FIRST" ] | ||
31 | then | ||
32 | FIRST= | ||
33 | ps $tab | ||
34 | (set -x | ||
35 | kill "$tab") | ||
36 | fi | ||
37 | ps $tab | ||
38 | done | ||