On Thu, Oct 28, 2021 at 12:01:35PM +0100, Dominic Raferd wrote:
> # obtain QIDs, if any
> QIDS=( $("$POSTQUEUE" -j|grep -F '"queue_name": "hold"'|"$JQ" '.arrival_time,
> .queue_id'|sed 'N;s/\n//;s/"/,/g'|awk -F, -v BEFORE="$BEFORE" '{if
> ($1<BEFORE) print $2}') )
> echo -n "${#QIDS[*]} mail(s) earlier than $1 found in postfix hold queue: "
Yes, "postqueue -j", "jq" and "postsuper -d - hold" are the right tools for
the job, but "grep" and "sed" really???
postqueue -j | jq -nr --argjson $days '
(now - 86400 * $days) as $too_old
| inputs
| select(.queue_name == "hold" and .arrival_time < $too_old)
| .queue_id
| select(test("^\\w+$")) # permit only valid queue-id syntax
' |
postsuper -d - hold
--
Viktor.