Emailing Sql-Ledger Reports using Cron

There is no built-in support in sql-ledger to email reports periodically but you can easily build a shell script which will do so. The trick is to call sql-ledger API through command line to generate the report into an html file and then use mutt to email the report.

For example following call to API from command line will generate the AR Outstanding report to an html file in /tmp folder. (backslash is continuation character)

/usr/local/www/data/sql-ledger/ "path=bin/mozilla\
&outstanding=1" > /tmp/outstanding.html

Once the report is generated, a mutt invocation will send the report to the intended recipient.

/usr/local/bin/mutt -a /tmp/outstanding.html \
-s 'Outstanding report' < /dev/null

Both these lines can be put into a shell script which can be run periodically through cron.

Leave a Reply