Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on rails scheduled tasks

This is my first time scheduling a task and I am not sure of the best implementation (or the proper implementation).

My Goal: I have a ruby on rails 4 app setup with twilio and deployed on Heroku. I want the app to automatically text all of my users once a week with a customized text message (which is written and created by information in the database).

From research I have come down to the following Gems: Whenever and Rufus-Scheduler.

I believe that both these gems can get the Job done, but upon reading on the Rufus' docs: "please note: rufus-scheduler is not a cron replacement" I got stuck trying to understand if what I want is indeed a cron job or a "Rufus-Scheduler".

I am left with the following questions: What is a cron job and when is the appropriate time to use it? Why is Rufus-Scheduler not a cron replacement and what does it do differently? Which one should I use?

like image 491
stecd Avatar asked Apr 30 '14 02:04

stecd


2 Answers

About Cron:

Cron is name of program which does scheduled tasks on nix systems. what Scheduled Tasks are in Windows, Cron does something similar for Linux at the conceptual level.Cron is one of the most useful tool in Linux or UNIX like operating systems. The cron service (daemon) runs in the background and constantly checks the /etc/crontab file, and /etc/cron./ directories. It also checks the /var/spool/cron/ directory.

For Scheduling tasks on Heroku

Good news is that on Heroku there is a thing called Scheduler which is an add-on for running jobs on your app at scheduled time intervals, much like cron in a traditional server environment. so you really don't need to fiddle/player with cron or gems like whenever. just use the Scheduler addon on Heroku.

For More info see: https://devcenter.heroku.com/articles/scheduler

like image 67
CuriousMind Avatar answered Sep 19 '22 16:09

CuriousMind


A cron job is a program run on an automated time schedule, using the cron software.

Rufus-Scheduler is different from cron because it runs inside of Ruby processes.

For what you're describing I believe either would be fine.

like image 27
Seanna Avatar answered Sep 21 '22 16:09

Seanna