Wednesday, June 18, 2008

script to grab data from a database

Travis shares a nifty method for cron jobs to grab data from a database at run time.

In the cron file I replace

30 10 2 * * $HOME/bin/ -sendmailto tjic


30 10 2 * * $HOME/bin/

and in the script (Ruby), I replace

puts "output" # write to stdout

with something like

ActionMailer.send_mail("fromaddr", Person.find(:all, :conditions => "email_bit_foobar = 1").join(","), "subject line", "body")

Blogged here so I'll remember it in a few weeks when I need it.

This might seem awkward but if you've got Ruby on your server it's no more awkward than using PERL. The database thing might be another problem. Except that with sqlite your database is a file and those can be mounted from an NFS drive. Or can you replicate a sqlite file from a central repository?
blog comments powered by Disqus