All pastes #2109003 Raw Edit

Untitled

public shellscript v1 · immutable
#2109003 ·published 2012-02-02 11:06 UTC
rendered paste body
#!/usr/bin/env bashfile="/tmp/cpustats"delay="10"set -o noclobber{ >"$file"; } &>/dev/null || { cat "$file"; exit 0; }set +o noclobberLC_ALL=C top -b -n 1 | grep "^Cpu" >"$file"cat "$file"exec 1>/dev/nullexec 2>/dev/null(        [[ -t 0 ]] && exec 0>/dev/null        [[ -t 1 ]] && exec 1>/dev/null        [[ -t 2 ]] && exec 2>/dev/null        trap : HUP        while read -r line; do                echo "$line" >"$file"        done < <(                LC_ALL=C top -b -d "$delay" | grep --line-buffered "^Cpu"        )) &disown