{"id":13685676,"url":"https://github.com/plashchynski/crono","last_synced_at":"2025-10-15T02:59:17.225Z","repository":{"id":27965421,"uuid":"31458503","full_name":"plashchynski/crono","owner":"plashchynski","description":"A time-based background job scheduler daemon (just like Cron) for Rails","archived":false,"fork":false,"pushed_at":"2024-12-18T11:59:49.000Z","size":1760,"stargazers_count":687,"open_issues_count":34,"forks_count":56,"subscribers_count":13,"default_branch":"main","last_synced_at":"2024-12-18T12:39:58.870Z","etag":null,"topics":["cron","crono","daemon","rails","ruby","schedule","scheduler"],"latest_commit_sha":null,"homepage":"https://github.com/plashchynski/crono","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/plashchynski.png","metadata":{"files":{"readme":"README.md","changelog":"Changes.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-28T09:52:21.000Z","updated_at":"2024-12-18T11:59:15.000Z","dependencies_parsed_at":"2023-12-20T10:33:25.989Z","dependency_job_id":"0fc4cda5-1677-441f-a494-cd0d9f4ae283","html_url":"https://github.com/plashchynski/crono","commit_stats":{"total_commits":276,"total_committers":23,"mean_commits":12.0,"dds":"0.15217391304347827","last_synced_commit":"4294bad43a7314920357c1fd4636a4f107d824a6"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plashchynski%2Fcrono","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plashchynski%2Fcrono/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plashchynski%2Fcrono/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plashchynski%2Fcrono/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plashchynski","download_url":"https://codeload.github.com/plashchynski/crono/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251824507,"owners_count":21649875,"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","crono","daemon","rails","ruby","schedule","scheduler"],"created_at":"2024-08-02T14:00:55.757Z","updated_at":"2025-10-15T02:59:12.181Z","avatar_url":"https://github.com/plashchynski.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"Job scheduler for Rails\n------------------------\n[![Gem Version](https://badge.fury.io/rb/crono.svg)](http://badge.fury.io/rb/crono)\n\nCrono is a time-based background job scheduler daemon (just like Cron) for Ruby on Rails.\n\n## The Purpose\n\nCurrently, there is no such thing as Ruby Cron for Rails. Well, there's [Whenever](https://github.com/javan/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.\n\n![Web UI](https://github.com/plashchynski/crono/raw/main/examples/crono_web_ui.png)\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    rails generate crono:install\n\nIt will create a configuration file `config/cronotab.rb` and migration  \nRun the migration:\n\n    rake db:migrate\n\nNow you are ready to move forward to create a job and schedule it.\n\n### Compatibility\n\n* **Crono v1.1.2** and older are compatible with Ruby 2.7.x and older\n* **Crono v2.0.0** and newer are compatible with Ruby 2.7.x and _newer_\n\n## Usage\n\n### The basic usage\n\nYou can specify a simple job by editing ```config/cronotab.rb```:\n\n```ruby\n# config/cronotab.rb\nclass TestJob\n  def perform\n    puts 'Test!'\n  end\nend\n\nCrono.perform(TestJob).every 5.seconds\n```\n\nThen, run a crono process:\n\n```bundle exec crono -e development```\n\n### Job Schedule\n\nSchedule list is defined in the file `config/cronotab.rb`, that created using `rake 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 serialized 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### Job classes\n\nCrono can use Active Job jobs from `app/jobs/`. Here's an example of a job:\n\n```ruby\n# app/jobs/test_job.rb\nclass TestJob \u003c ActiveJob::Base\n  def perform(options)\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\n### Run rake tasks\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'].execute\n  end\nend\n\nCrono.perform(Test).every 5.seconds\n```\nWith the rake task of:\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### Run crono\n\nRun crono in your Rails project root directory:\n\n    bundle exec crono -e development\n\nUsage:\n```\nUsage: crono [options] [start|stop|restart|run]\n    -C, --cronotab PATH              Path to cronotab file (Default: config/cronotab.rb)\n    -L, --logfile PATH               Path to writable logfile (Default: log/crono.log)\n    -P, --pidfile PATH               Deprecated! use --piddir with --process_name; Path to pidfile (Default: )\n    -D, --piddir PATH                Path to piddir (Default: tmp/pids)\n    -N, --process_name NAME          Name of the process (Default: crono)\n    -m, --monitor                    Start monitor process for a deamon (Default false)\n    -e, --environment ENV            Application environment (Default: development)\n```\n\n### Run as a daemon\n\nTo run Crono as a daemon, please add to your Gemfile:\n\n```ruby\ngem 'daemons'\n```\n\nThen:\n\n    bundle install; bundle exec crono start RAILS_ENV=development\n\nThere are \"start\", \"stop\", and \"restart\" commands.\n\n## Web UI\n\nCrono can display the current state of Crono jobs.  \n\nAdd the following to your `config/routes.rb`:\n\n```ruby\nRails.application.routes.draw do\n    mount Crono::Engine, at: '/crono'\n    ...\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`require': cannot load such file -- rack/showexceptions (LoadError)\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## Development\n\n### Running tests\n\nTo run the tests, you need to have a database. You can use the default SQLite database:\n\n    bundle exec rspec\n\n### Publishing\n\nTo publish a new version, you need to update the version number in `lib/crono/version.rb` and then run:\n\n    bundle exec rake release\n\n\n## Support\n\nFeel free to create an [issues](https://github.com/plashchynski/crono/issues)\n\n\n## License\n\nPlease see [LICENSE](LICENSE) for licensing details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplashchynski%2Fcrono","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplashchynski%2Fcrono","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplashchynski%2Fcrono/lists"}