2111e2c78f85b7b8113d42c5726e7f3957950c87
2 # Desc: Writes stdin to disk every 5 minutes
4 yell
() { echo "[$(date --iso-8601=ns)]:$0: $*" >&2; } #o Yell, Die, Try Three-Fingered Claw technique
5 die
() { yell
"$*"; exit 111; } #o Ref/Attrib: https://stackoverflow.com/a/25515370
6 try
() { "$@" || die
"cannot $*"; } #o
8 declare -a buffer
# Initialize buffer array
13 printf "%s\n" "${buffer[@]}" >> /dev
/shm
/$
(date +%s
)..bkFreqWrite-output.txt
;
17 # Run until script TTL seconds pass
18 while [[ $SECONDS -lt "scriptTTL" ]]; do
19 bufferTOD
="$((SECONDS + $bufferTTL))";
21 # Consume stdin to fill buffer until buffer time-of-death (TOD) arrives
22 while read -r line
&& [[ $SECONDS -lt "$bufferTOD" ]]; do
23 # Append line to buffer
25 echo "Processing line:$lineCount";
26 echo "Current line :$line";
27 echo "buf elem count :${#buffer[@]}";
30 # Export buffer to asynchronous processing.
33 # Increment buffer round
37 # Author: Steven Baltakatei Sandoval