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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With