Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A sample app using Clockwork with a Sinatra/Beanstalk app to fetch market prices periodically
Branch: master
Failed to load latest commit information.
.gitignore init
Gemfile init
Procfile init readme
clock.rb init
jobs.rb init
market_point.rb init
web.rb init

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://
$ 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.

Something went wrong with that request. Please try again.