CronJob to send automatic custom CDR email

To the preserve the easy to read “asci box” around the text output add -t (I believe that is undocumented in the man file :wink: ) as a mysql argument, not as pretty as -H but works over every mail client.

for the -s argument check out

echo “$(date --date=‘yesterday’ +‘Call Report_%Y_%m_%d’)”

for convenience emailing I suggest you install mutt , it has an -a (attach file) argument , hence redirect the output of the sql query into report.txt and then:-

echo "attachment for report of $(date --date=‘yesterday’ +’%Y/%m/%d’) "| mutt -s “$(date --date=‘yesterday’ +‘Call Report_%Y_%m_%d’)” -a report.txt – [email protected]

(edit:- as you can see, there are many ways to skin a cat in linux :wink: if you just want a CSV file perhaps for other use, look into adding to the mysql query

INTO OUTFILE ‘/tmp/report.txt’ FIELDS TERMINATED BY ‘,’ OPTIONALLY ENCLOSED BY ‘"’

mysql by default can only OUTFILE into it’s home folder /var/lib/mysql and /tmp, don’t forget to delete the file after use

)