A sample app using Clockwork with a Sinatra/Beanstalk app to fetch market prices periodically
Latest commit 4cb81ab Jul 1, 2010 @adamwiggins readme
Failed to load latest commit information.
.gitignore init Jun 29, 2010
Gemfile init Jun 29, 2010
Procfile init Jun 29, 2010
README.md readme Jun 30, 2010
clock.rb init Jun 29, 2010
jobs.rb init Jun 29, 2010
market_point.rb init Jun 29, 2010
web.rb init Jun 29, 2010


Sample Clockwork App (Sinatra/Beanstalk)

Clockwork is a library to replace cron for scheduling jobs from within an application. This is a sample application which uses the Sinatra web framework, a MongoDB database, and the Beanstalk queueing backend to demonstrate Clockwork's use.

The app fetches the Dow Jones index from Google Finance once every three minutes, and puts the results in the Mongo database. The web app shows the history of all fetched data points.


  • Ruby
  • Bundler (gem install bundler)
  • Beanstalkd (brew install beanstalk)
  • MongoDB (brew install mongodb)


$ git clone git://github.com/adamwiggins/clockwork-sinatra-beanstalk.git
$ cd clockwork-sinatra-beanstalk
$ bundle install

Running the db and queue

$ mkdir -p data; mongod --dbpath data &
$ beanstalkd &

Running the app

$ bundle exec ruby web.rb &
$ bundle exec stalk jobs.rb & 
$ bundle exec clockwork clock.rb &

Alternately, use Foreman (gem install foreman):

$ foreman start

Visit http://localhost:4567/ and you should see the first data point.