Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

whenever gem have cronjob on only one machine?

We have a large deployment of around a dozen servers. We'd like to use the Whenever gem but I can't figure out a way to say which machine the cron jobs should go on! We only want these jobs to run on our server that does background jobs.

Is there a way to specify this?

like image 229
phil Avatar asked Feb 21 '11 10:02

phil


People also ask

Do Cronjobs run automatically?

The cron reads the crontab (cron tables) for running predefined scripts. By using a specific syntax, you can configure a cron job to schedule scripts or other commands to run automatically.

What are Cronjobs used for?

A cron job is the scheduled task itself. Cron jobs can be very useful to automate repetitive tasks. For example, you can set a cron job to delete temporary files every week to conserve your disk space. Some programs, such as Drupal, may require you to set up a cron job to perform certain functions.

What is Cronjob?

Cron Jobs allow you to automate specific commands or scripts on your server to complete repetitive tasks automatically. This can be a very resourceful tool as a Cron Job can be set to run by 15 minute or hourly increments, a day of the week or month, or any combination of these.


1 Answers

If you deploy the project with Capistrano and you use the default Whenever recipe, you can create a new Capistrano role

role :whenever, "192.168.1.1"

and set the role in your deploy.rb file

set :whenever_roles, "whenever"

In this way, the task will be executed only on the specified server.

like image 139
Simone Carletti Avatar answered Oct 03 '22 19:10

Simone Carletti