whenever

Rails cron with whenever, setting the environment

梦想与她 提交于 2019-12-03 01:58:19
问题 This question will probably only make sense if you know about the whenever gem for creating cron jobs. I have a task in my schedule.rb like every 1.day, :at => '4am' do command "cd #{RAILS_ROOT} && rake thinking_sphinx:stop RAILS_ENV=#{RAILS_ENV}" command "cd #{RAILS_ROOT} && rake thinking_sphinx:index RAILS_ENV=#{RAILS_ENV}" command "cd #{RAILS_ROOT} && rake thinking_sphinx:start RAILS_ENV=#{RAILS_ENV}" end However when I update my crontab using whenever --update-crontab appname --set

How to detect Rails environment inside whenever

廉价感情. 提交于 2019-12-03 00:09:29
This question will probably only make sense if you know about the whenever gem for creating cron jobs. For my app, I want to use whenever in all the environments, including testing and development . My schedule.rb looks like this: set :output, { :error => "#{path}/log/error.log", :standard => "#{path}/log/cron.log" } set :environment, Rails.env.to_sym every 5.minutes do rake 'db:activity:synchronize' end but it fails on Rails.env.to_sym ( and the same stands for RAILS_ENV ): /home/marius/.rvm/gems/ruby-1.9.2-p290@uxolo/gems/whenever-0.6.8/lib/whenever/job_list.rb:21:in `eval': uninitialized

Is Rails's “delayed_job” for cron task really?

这一生的挚爱 提交于 2019-12-02 23:59:10
delayed_job is at http://github.com/collectiveidea/delayed_job Can delayed_job have the ability to do cron task? Such as running a script every night at 1am. Or run a script every 1 hour. If not, what are the suitable gems that can do that? And can it be monitored remotely using a browser, and have logging of success and error? I worked on a project that tried to use DelayedJob to schedule future items. It sucked. Instead I recommend you use the whenever gem: http://github.com/javan/whenever Whenever is a Ruby gem that provides a clear syntax for defining cron jobs. It outputs valid cron

whenever gem have cronjob on only one machine?

倖福魔咒の 提交于 2019-12-02 23:18:20
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? 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. whenever is preconfigured to run

Rails whenever gem: each month on the 20th

∥☆過路亽.° 提交于 2019-12-02 23:08:16
I searched all over the internet for this, and the documentation isn't really talking about monthly jobs in specific. So I was hoping that someone here could tell me how to do this. I've installed the whenever gem and all I need to know is the right syntax for this: every :month, :on => '20th', :at => '02:00' do runner "Mailer.send_friend_sheet" end Hope someone can point me in the right direction.. Thanks! Whenever doesn't support an :on option as far as I am aware, but you should be able to do every '0 2 20 * *' do runner "Mailer.send_friend_sheet" end The '0 2 20 * *' is simply the relevant

Sidekiq Rails 4.2 Use Active Job or Worker? What's the difference

烂漫一生 提交于 2019-12-02 17:40:19
This is my first processing jobs asynchronously I am implementing Sidekiq for background processing in my app. I will use it for reminder emails and in-app notifications. I am confused as to whether I should use Active Job to create a job that sends an email or a Sidekiq Worker to send an email. They seem to do the same thing and Rails 4.2 Active Job seems very new…is it replacing the need for a Sidekiq Worker? Below is the same sending a mailer code using an Active Job job and a Sidekiq Worker. I am using Whenever gem for scheduling. my_mailers.rb class MyMailers < ActionMailer::Base def some

Rails cron with whenever, setting the environment

故事扮演 提交于 2019-12-02 17:07:43
This question will probably only make sense if you know about the whenever gem for creating cron jobs. I have a task in my schedule.rb like every 1.day, :at => '4am' do command "cd #{RAILS_ROOT} && rake thinking_sphinx:stop RAILS_ENV=#{RAILS_ENV}" command "cd #{RAILS_ROOT} && rake thinking_sphinx:index RAILS_ENV=#{RAILS_ENV}" command "cd #{RAILS_ROOT} && rake thinking_sphinx:start RAILS_ENV=#{RAILS_ENV}" end However when I update my crontab using whenever --update-crontab appname --set environment=production the cron jobs still have RAILS_ENV=development. My tasks on production and development

Whenever cron job is not working in rails 3

空扰寡人 提交于 2019-12-01 06:12:27
This is the code in my schedule file. I am using 1 min just to test whether its working or not. every 1.minutes do runner "User.update_all('daily_sms_count' = 0 )" end from terminal i setup whenever --set environment=development --update-crontab 1mintesting Whats the issue? Are you using RVM? If so, Whenever generates a crontab entry like this: * * * * * /bin/bash -l -c 'cd /Users/myuser/Documents/Projects/foo && script/rails runner -e development '\''User.update_all("daily_sms_count" = 0 )'\''' This means that it won't necessarily be using your project's version of Ruby and associated gemset

Whenever cron job is not working in rails 3

▼魔方 西西 提交于 2019-12-01 05:54:58
问题 This is the code in my schedule file. I am using 1 min just to test whether its working or not. every 1.minutes do runner "User.update_all('daily_sms_count' = 0 )" end from terminal i setup whenever --set environment=development --update-crontab 1mintesting Whats the issue? 回答1: Are you using RVM? If so, Whenever generates a crontab entry like this: * * * * * /bin/bash -l -c 'cd /Users/myuser/Documents/Projects/foo && script/rails runner -e development '\''User.update_all("daily_sms_count" =

Whenever - Cron not working? Permission denied

ⅰ亾dé卋堺 提交于 2019-11-30 20:31:16
'I have set up a cron with wehenever, but its not working. I tried to run the command manually and i get the error /bin/bash: bin/rails: Permission denied . Here what the command of the cron looks like: /bin/bash -l -c 'cd /var/www/domain.net/main && bin/rails runner -e production '\''User.weekly_update'\''' I also tried to run this command as root but i got the same message. Try to make bin/rails executable: chmod u+x bin/rails This is, of course, assuming that bin/rails is owned by the crontab's user. I found that use of RVM can complicate this. A worthy alternative is to make your whenever