Posted 4 months ago. Visible to the public. Repeats.

Whenever: Don't forget leading zeros for hours!

Whenever is a Ruby gem that provides a nicer syntax for writing and deploying cron jobs.

Leading zeros are important for whenever if you use the 24-hours format!

This schedule.rb:

Copy
every 1.day, at: '3:00', roles: [:primary_cron] do runner 'Scheduler.delay.do_things' end

will lead to this crontab entry (crontab -l):

Copy
0 15 * * * /bin/bash -l -c 'cd /var/www/my-project/releases/20180607182518 && bin/rails runner -e production '\''Scheduler.delay.do_things'\'''

Which would run on 3pm instead of 3am.

Using the leading zero will lead to the expected behaviour:

schedule.rb

Copy
every 1.day, at: '03:00', roles: [:primary_cron] do runner 'Scheduler.delay.do_things' end

crontab -l:

Copy
0 3 * * * /bin/bash -l -c 'cd /var/www/my-project/releases/20180608095252 && bin/rails runner -e staging '\''Scheduler.delay.do_things'\'''

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Judith Roth
Last edit:
4 months ago
by Thomas Eisenbarth
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Judith Roth to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more