Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

crono

> 后端框架
Open source

A time-based background job scheduler daemon (just like Cron) for Rails

684 stars0 likes2 views
WebsiteGitHub

About

A time-based background job scheduler daemon (just like Cron) for Rails

Job scheduler for Rails

Crono is a time-based background job scheduler daemon (just like Cron) for Ruby on Rails.

The Purpose

Currently, there is no such thing as Ruby Cron for Rails. Well, there's Whenever but it works on top of Unix Cron, so you can't manage it from Ruby. Crono is pure Ruby. It doesn't use Unix Cron and other platform-dependent things. So you can use it on all platforms supported by Ruby. It persists job states to your database using Active Record. You have full control of jobs performing process. It's Ruby, so you can understand and modify it to fit your needs.

Installation

Add the following line to your application's Gemfile:

ruby
gem 'crono'

Run the bundle command to install it.
After you install Crono, you can run the generator:

rails generate crono:install

It will create a configuration file config/cronotab.rb and migration
Run the migration:

rake db:migrate

Now you are ready to move forward to create a job and schedule it.

Compatibility

  • Crono v1.1.2 and older are compatible with Ruby 2.7.x and older
  • Crono v2.0.0 and newer are compatible with Ruby 2.7.x and newer

Usage

The basic usage

You can specify a simple job by editing config/cronotab.rb:

ruby
# config/cronotab.rb
class TestJob
  def perform
    puts 'Test!'
  end
end

Crono.perform(TestJob).every 5.seconds

Then, run a crono process:

bundle exec crono -e development

Job Schedule

Schedule list is defined in the file config/cronotab.rb, that created using rake crono:install. The semantic is pretty straightforward:

ruby
# config/cronotab.rb
Crono.perform(TestJob).every 2.days, at: {hour: 15, min: 30}
Crono.perform(TestJob).every 1.week, on: :monday, at: "15:30"

You can schedule one job a few times if you want the job to be performed a few times a day or a week:

ruby
Crono.perform(TestJob).every 1.week, on: :monday
Crono.perform(TestJob).every 1.week, on: :thursday

The at can be a Hash:

ruby
Crono.perform(TestJob).every 1.day, at: {hour: 12, min: 15}

You can schedule a job with arguments, which can contain objects that can be serialized using JSON.generate

ruby
Crono.perform(TestJob, 'some', 'args').every 1.day, at: {hour: 12, min: 15}

You can set some options that not passed to the job but affect how the job will be treated by Crono. For example, you can set to truncate job logs (which stored in the database) to a certain number of records:

ruby
Crono.perform(TestJob).with_options(truncate_log: 100).every 1.week, on: :monday

Job classes

Crono can use Active Job jobs from app/jobs/. Here's an example of a job:

ruby
# app/jobs/test_job.rb
class TestJob  :environment do
    puts "hello"
  end
end

Please note that crono uses threads, so your code should be thread-safe

Run crono

Run crono in your Rails project root directory:

bundle exec crono -e development

Usage:

…

Run as a daemon

To run Crono as a daemon, please add to your Gemfile:

ruby
gem 'daemons'

Then:

bundle install; bundle exec crono start RAILS_ENV=development

There are "start", "stop", and "restart" commands.

Web UI

Crono can display the current state of Crono jobs.

Add the following to your config/routes.rb:

ruby
Rails.application.routes.draw do
    mount Crono::Engine, at: '/crono'
    ...

Access management and other questions described in the wiki.

Known issues

For Rails 5, in case of the errors:

`require': cannot load such file -- rack/showexceptions (LoadError)

See the related issue #52

Capistrano

Use the capistrano-crono gem (github).

Development

Running tests

To run the tests, you need to have a database. You can use the default SQLite database:

bundle exec rspec

Publishing

To publish a new version, you need to update the version number in lib/crono/version.rb and then run:

bundle exec rake release

Support

Feel free to create an issues

License

Please see LICENSE for licensing details.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rubycroncronodaemonrails

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架