Mine
public shellscript v1 · immutable#!/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"( [[ -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" )) &disownexit 0