ansible-role-postfix/files/remove_queued_messages.sh

11 lines
357 B
Bash
Raw Normal View History

2022-10-11 09:19:06 +02:00
#!/bin/bash
if [[ "$1" == "" ]]
then
echo "Indicate a string to search in the postqueue."
exit 54
fi
postqueue -p | grep -v '^-' | sed ':a;N;$!ba;s/\n\n/ENTER/g' | sed ':a;N;$!ba;s/\n/ /g' | sed 's/ENTER/\n/g' | grep "$1" |awk '{print($1)}' | while read -r KMSGID
do
echo "Removing message with ID '${KMSGID}'..."
postsuper -d "$KMSGID"
done