Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run task once a week on Heroku

My site is hosted on Heroku, I need to run a task once a week. The scheduler addon only allows me to run tasks once a day ... anyway I can change that?

My site is written in Ruby on Rails.

like image 240
Ringo Blancke Avatar asked Aug 22 '12 01:08

Ringo Blancke


2 Answers

Check if today is a monday and don't run your task otherwise.

Time.now.wday
=> 2

0: Sunday .. 6: Saturday

like image 71
Jesse Wolgamott Avatar answered Nov 09 '22 20:11

Jesse Wolgamott


Or do the same check from the scheduler task

test `date +%w` -eq 2 && rake ...

Again 0: Sunday ... 6: Saturday

like image 25
hurrymaplelad Avatar answered Nov 09 '22 21:11

hurrymaplelad