Parsing Linux maillogs for bounces

 

# Take yesterdays root emails and moves it to production server .
# Run as prod connect as application account.
# Only root can read the maillogs

cp /var/mail/root /app_data/maillog/rootmail.`TZ=CST+24 date +%Y%m%d`.dat
> /var/mail/root

cat /app_data/maillog/rootmail.`TZ=CST+24 date +%Y%m%d`.dat | egrep '(Final-Recipient:)|(Diagnostic-Code:)' > /app_data/maillog/MR.$HOSTNAME.`TZ=CST+24 date +%Y%m%d`.dat

touch /app_data/maillog/MR.$HOSTNAME.`TZ=CST+24 date +%Y%m%d`.ctl

scp /app_data/maillog/MR.$HOSTNAME.`TZ=CST+24 date +%Y%m%d`.dat  <appusername>@<myprodcentralserver>:/app_data/LoadFile/webp1/web_admin/DownLoaded/MR.$HOSTNAME.`TZ=CST+24 date +%Y%m%d`.dat

scp /app_data/maillog/MR.$HOSTNAME.`TZ=CST+24 date +%Y%m%d`.ctl  <appusername>@<myprodcentralserver>:/app_data/LoadFile/webp1/web_admin/DownLoaded/MR.$HOSTNAME.`TZ=CST+24 date +%Y%m%d`.ctl