Skip to content

Instantly share code, notes, and snippets.

@pawel-dubiel
Last active August 29, 2015 14:08
Show Gist options
  • Save pawel-dubiel/053e0c784b004adc3214 to your computer and use it in GitHub Desktop.
Save pawel-dubiel/053e0c784b004adc3214 to your computer and use it in GitHub Desktop.
count mails
#!/bin/bash
#count_email_log
#add to cron
#59 23 * * * root /bin/count_email_log
IFS='%'
touch /var/www/mail.txt || exit
VOUTME="$(mktemp)"
VCURRENTDATE=$(date "+%b %-d")
VCURRENTDATEFULL=$(date "+%b.%-d.%y")
grep "$VCURRENTDATE" /var/www/mail.txt > $VOUTME
VCOUNT="$(grep -c "Message accepted for delivery" "$VOUTME")"
echo "$VCURRENTDATEFULL $VCOUNT emails sent" >> /var/www/mail.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment