From e52e5ea5494319f158e9d9c1425b16b9986e929a Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 6 Apr 2018 19:54:03 +0200 Subject: rss_staggered --- odin/strm/rss_staggered | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 odin/strm/rss_staggered (limited to 'odin/strm') diff --git a/odin/strm/rss_staggered b/odin/strm/rss_staggered new file mode 100755 index 00000000..54bbd1a3 --- /dev/null +++ b/odin/strm/rss_staggered @@ -0,0 +1,32 @@ +#!@zsh@/bin/zsh + +delta_t=20 +interval=3600 + +staggerFile=~/.rss-stagger + +[[ "${FLOCKER}" != "$0" ]] && exec env FLOCKER="$0" flock -x "${staggerFile}" "$0" "$@" || : + +feeds=$(@rss2email@/bin/r2e list | awk -F ':' 'END { print $1; }') +max=$(($feeds + 1)) +num=$(((max * delta_t) / interval)) +[[ $num -lt 1 ]] && num=1 + +now=$(cat ${staggerFile} || echo 0) +now=$((now % max)) + +typeset -a run +run=() +typeset -a names +names=() + +n=0 + +for i in $(seq $((now + 1)) $((now + num + 1))); do + n=$((i % max)) + run+=$n +done + +echo $n >! ${staggerFile} + +exec @rss2email@/bin/r2e run $run -- cgit v1.2.3