diff options
Diffstat (limited to 'bin/msmtp-queue-stat')
| -rwxr-xr-x | bin/msmtp-queue-stat | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bin/msmtp-queue-stat b/bin/msmtp-queue-stat new file mode 100755 index 0000000..bb83784 --- /dev/null +++ b/bin/msmtp-queue-stat @@ -0,0 +1,17 @@ +#!/bin/sh +set -eu + +throttle_by=10 +throttle_cookie=/tmp/throttle.msmtp-queue-stat +throttle() { + last_called=$(stat -c %Y $throttle_cookie 2>/dev/null || printf 0) + now=$(date +%s) + touch $throttle_cookie + if [ $((now - last_called)) -gt $throttle_by ]; then + "$@" + else + false + fi +} + +throttle sh -c "msmtpq --q-mgmt -d | grep id= | wc -l | tee $throttle_cookie" || cat "$throttle_cookie" |