# Active Job Rails Cron Job

**URL:** <https://community.fly.io/t/active-job-rails-cron-job/13674>\
**Category:** Questions / Help\
**Tags:** rails, login-only\
**Created:** [June 21, 2023, 2:31pm UTC](https://community.fly.io/t/active-job-rails-cron-job/13674 "2023-06-21T14:31:13Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Hexin](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/hexin/32/13233_2.png) [@Hexin](https://community.fly.io/u/Hexin)\
**Post date:** [June 28, 2023, 8:28pm UTC](https://community.fly.io/t/active-job-rails-cron-job/13674/6 "2023-06-28T20:28:35Z")

</div>

Sorry for the late response folks, but got everything working. Many thanks for your help!

My final solution ended up using:

- supercronic by following [Recurring scheduled tasks (like cron)](https://community.fly.io/t/recurring-scheduled-tasks-like-cron/1431). I execute my Active Job as a rake task that I had to define.

- Using Rails Active Job along with the “inline” queue backend to execute the task immediately. I would like to use something like Sidekiq down the line, but I didn’t want to fuss around with it and I wasn’t sure if I would need to run that in yet another process. The inline backend will probably work fine for a while.

- Some docs for setting up the .toml file were a little unclear to me. Especially, it wasn’t clear how to migrate from using the default [http\_service] to [[services]]. Some trial and error later, this worked:

```auto
app = "campusninja"
primary_region = "ams"
console_command = "/rails/bin/rails console"

[processes]
  web = "./bin/rails server"
  cron = "supercronic ./crontab"

[[statics]]
  guest_path = "/rails/public"
  url_prefix = "/"

[[services]]
  processes = ["web"] # this service only applies to the web block
  http_checks = []
  internal_port = 3000
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

```

A plug-and-play solution would be really cool, but this also works. Thanks!

---

_[View the full topic](https://community.fly.io/t/active-job-rails-cron-job/13674)._
