How to reschedule job with ActiveJob every end of month plus X days without crontab?

I a’m trying to rechedule job automatically. For example

  1. On January 1st, an admin activates the monthly auto-wire at +15 days for client John
  2. We schedule a job in sidekiq to run on January 31st + 15 days so the ~ February 15th
  3. On February 15, sidekiq performs the job alone, without cron or intervention on our part, he sends the invoice
  4. After sending the invoice, we re-schedule a job in sidekiq to run on February 31 + 15 days, so March 15
  5. and so on

class ClientProfile
include Mongoid::Document
def set_auto_wire_sending_date
AutoWireJob.set(wait_until: (today.end_of_month + 15.days).to_time).perform_later(

def today


class AutoWireJob < ActiveJob::Base
queue_as :autowire
after_perform :reschedule_job
def perform(user_id)
user = User.find(user_id)
# send the invoice

def reschedule_job
user = User.find(self.arguments.first)
client = user.client_profile
self.class.set(wait_until: ).perform_later(

def today

I expect to have recurring job but it executes only one time. What is wrong?

Time class.


If == 00 && ==00 && == 00
sudo apt-get update.

There’s also and

I did this on the go. Now that I have some time to explain it.

With the Time methods you can automate practically anything. I never liked Cron and never use it.
def auto_update
If == 31 && == 23 && == 00 ;
Kernal.system “sudo apt-get update”


By creating a .rb file with all of your tasks like so, or even individual files for each task, you can start them automatically two ways.

.rc_local (this starts all scripts at boot level, or when the bootloader starts the computer)
.bash_rc (this starts all scripts at the user login level. Meaning the files won’t start until that user logs in)
Using .bash_rc is a easier route and can be found in the /home/$USER Folder. I recommend this for newer users. Also you don’t have to edit the .bash_rc file directly. You can create a new file in your user folder as .bash_elias to load all your scripts at.

Ruby /home/$USER/path/to/script/task_manager.rb &

The & at the end is very important. It throws the task manager.rb into a big process. The same line would be added to the .rc_local file including the &.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs