Automatically start a long-running process?

I need to run a query every 10 seconds or so on my DB, and take certain actions if necessary. The way I've been doing this is to have a class method that contains an infinite loop. I start this method with an init script that calls script/runner. I'm wondering if there's a better way to do this - for instance, could I somehow start that method when my app starts up and thread it out? What I have works, but it seems that there should be a more graceful way to do it.
Jason