{"id":18513345,"url":"https://github.com/jbox-web/crono","last_synced_at":"2025-10-26T14:32:22.446Z","repository":{"id":146101146,"uuid":"253136873","full_name":"jbox-web/crono","owner":"jbox-web","description":"Crono is a time-based background job scheduler daemon (just like Cron) for Ruby on Rails.","archived":false,"fork":false,"pushed_at":"2025-07-01T23:59:37.000Z","size":1752,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-02T00:29:34.397Z","etag":null,"topics":["cron","crontab","job-crono","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbox-web.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-05T02:03:21.000Z","updated_at":"2025-07-01T23:59:40.000Z","dependencies_parsed_at":"2023-10-03T02:56:29.675Z","dependency_job_id":"5e2e857d-f967-4858-ac10-6c78b06b3975","html_url":"https://github.com/jbox-web/crono","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/jbox-web/crono","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Fcrono","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Fcrono/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Fcrono/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Fcrono/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbox-web","download_url":"https://codeload.github.com/jbox-web/crono/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbox-web%2Fcrono/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265205680,"owners_count":23727511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cron","crontab","job-crono","rails","ruby"],"created_at":"2024-11-06T15:37:45.902Z","updated_at":"2025-10-26T14:32:17.422Z","avatar_url":"https://github.com/jbox-web.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Crono - Job scheduler for Rails\n\n[![GitHub license](https://img.shields.io/github/license/jbox-web/crono.svg)](https://github.com/jbox-web/crono/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/jbox-web/crono.svg)](https://github.com/jbox-web/crono/releases/latest)\n[![CI](https://github.com/jbox-web/crono/workflows/CI/badge.svg)](https://github.com/jbox-web/crono/actions)\n[![Code Climate](https://codeclimate.com/github/jbox-web/crono/badges/gpa.svg)](https://codeclimate.com/github/jbox-web/crono)\n[![Test Coverage](https://codeclimate.com/github/jbox-web/crono/badges/coverage.svg)](https://codeclimate.com/github/jbox-web/crono/coverage)\n\nCrono is a time-based background job scheduler daemon (just like Cron) for Ruby on Rails.\n\n\n## The Purpose\n\nCurrently, there is no such thing as Ruby Cron for Rails.\n\nWell, there's [Whenever](https://github.com/javan/whenever) but it works on top of Unix Cron, so you can't manage it from Ruby.\n\nCrono 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.\nIt persists job states to your database using Active Record. You have full control of jobs performing process.\nIt's Ruby, so you can understand and modify it to fit your needs.\n\n![Web UI](https://github.com/plashchynski/crono/raw/master/examples/crono_web_ui.png)\n\n\n## Requirements\n\nTested with latest MRI Ruby 2.5+, 2.6+, 2.7+, Rails 5.\\*, and Rails 6.\\*.\nOther versions are untested but might work fine.\n\n\n## Installation\n\nAdd the following line to your application's Gemfile:\n\n```ruby\ngem 'crono'\n```\n\nRun the `bundle` command to install it.\nAfter you install Crono, you can run the generator:\n\n```sh\nbin/rails generate crono:install\n```\n\nIt will create a configuration file `config/cronotab.rb` and migration\nRun the migration:\n\n```sh\nbin/rails db:migrate\n```\n\nNow you are ready to move forward to create a job and schedule it.\n\n\n## Usage\n\n#### Create Job\n\nCrono can use Active Job jobs from `app/jobs/`. The only requirement is that the `perform` method should take no arguments.\n\nHere's an example of a job:\n\n```ruby\n# app/jobs/test_job.rb\nclass TestJob \u003c ActiveJob::Base\n  def perform\n    # put you scheduled code here\n    # Comments.deleted.clean_up...\n  end\nend\n```\n\nThe ActiveJob jobs are convenient because you can use one job in both periodic and enqueued ways. But Active Job is not required. Any class can be used as a crono job if it implements a method `perform`:\n\n```ruby\nclass TestJob # This is not an Active Job job, but pretty legal Crono job.\n  def perform(*args)\n    # put you scheduled code here\n    # Comments.deleted.clean_up...\n  end\nend\n```\n\nHere's an example of a Rake Task within a job:\n\n```ruby\n# config/cronotab.rb\nrequire 'rake'\n\nRails.app_class.load_tasks\n\nclass Test\n  def perform\n    Rake::Task['crono:hello'].invoke\n  end\nend\n\nCrono.perform(Test).every 5.seconds\n```\n\nWith the rake task of:\n\n```ruby\n# lib/tasks/test.rake\nnamespace :crono do\n  desc 'Update all tables'\n  task :hello =\u003e :environment do\n    puts \"hello\"\n  end\nend\n```\n\n_Please note that crono uses threads, so your code should be thread-safe_\n\n#### Job Schedule\n\nSchedule list is defined in the file `config/cronotab.rb`, that created using `crono:install`. The semantic is pretty straightforward:\n\n```ruby\n# config/cronotab.rb\nCrono.perform(TestJob).every 2.days, at: { hour: 15, min: 30 }\nCrono.perform(TestJob).every 1.week, on: :monday, at: \"15:30\"\n```\n\nYou can schedule one job a few times if you want the job to be performed a few times a day or a week:\n\n```ruby\nCrono.perform(TestJob).every 1.week, on: :monday\nCrono.perform(TestJob).every 1.week, on: :thursday\n```\n\nThe `at` can be a Hash:\n\n```ruby\nCrono.perform(TestJob).every 1.day, at: { hour: 12, min: 15 }\n```\n\nYou can schedule a job with arguments, which can contain objects that can be\nserialized using JSON.generate\n\n```ruby\nCrono.perform(TestJob, 'some', 'args').every 1.day, at: { hour: 12, min: 15 }\n```\n\nYou 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:\n\n```ruby\nCrono.perform(TestJob).with_options(truncate_log: 100).every 1.week, on: :monday\n```\n\n#### Run\n\nTo run Crono, first add it to your project as a binstub :\n\nIn your Rails project root directory:\n\n```sh\nbundle binstubs crono\n```\n\nthen :\n\n```sh\nbin/crono --help\n```\n\ncrono usage:\n\n```sh\nUsage: crono [options]\n    -C, --cronotab PATH              Path to cronotab file (Default: config/cronotab.rb)\n    -e, --environment ENV            Application environment (Default: development)\n```\n\n#### Run as a daemon\n\nTo run Crono as a daemon, please use systemd or supervisor.\n\n* [systemd config sample](https://github.com/jbox-web/crono/blob/master/examples/systemd/crono.service)\n* [monit config sample](https://github.com/jbox-web/crono/blob/master/examples/monit/monitrc.conf)\n\n## Web UI\n\nCrono comes with a Sinatra application that can display the current state of Crono jobs.\nAdd `sinatra` and `haml` to your Gemfile\n\n```ruby\ngem 'haml'\ngem 'sinatra', require: nil\n```\n\nAdd the following to your `config/routes.rb`:\n\n```ruby\nRails.application.routes.draw do\n  mount Crono::Web, at: '/crono'\n  ...\nend\n```\n\nAccess management and other questions described in the [wiki](https://github.com/plashchynski/crono/wiki/Web-UI).\n\n#### Known issues\n\nFor Rails 5, in case of the errors:\n\n```ruby\n`require': cannot load such file -- rack/showexceptions (LoadError)\n```\n\nSee the related issue [#52](https://github.com/plashchynski/crono/issues/52)\n\n\n## Capistrano\n\nUse the `capistrano-crono` gem ([github](https://github.com/plashchynski/capistrano-crono/)).\n\n\n## Support\n\nFeel free to create [issues](https://github.com/jbox-web/crono/issues)\n\n\n## Known Issues\n\n* Is not compatible with the `protected_attributes` gem. See: [#43](https://github.com/plashchynski/crono/issues/43)\n\n\n## License\n\nPlease see [LICENSE](https://github.com/jbox-web/crono/blob/master/LICENSE) for licensing details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbox-web%2Fcrono","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbox-web%2Fcrono","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbox-web%2Fcrono/lists"}