whenever icon indicating copy to clipboard operation
whenever copied to clipboard

cap development whenever:update_crontab silently succeeds, does nothing

Open chronodm opened this issue 9 years ago • 7 comments
trafficstars

When I run cap development whenever:update_crontab, it appears to silently succeed, with no output, and the crontab on the server is not updated. Likewise, cap development deploy shows no whenever-related activity.

In my Capfile:

require 'whenever/capistrano'

In deploy/development.rb:

In my deploy.rb:

set :whenever_identifier, -> { "#{fetch(:application)}_#{fetch(:stage)}" }
set :whenever_environment, -> { fetch(:stage, 'production') }

My schedule.rb:

set :output, 'logs/dash2-harvester.log'

every 15.minutes do
  command "STASH_ENV=#{@environment} /apps/dash2/apps/dash2-harvester/bin/harvest.sh"
end

chronodm avatar Apr 21 '16 23:04 chronodm

I can manually run bundle exec whenever --update-crontab on the deployed server, and that works.

chronodm avatar Apr 21 '16 23:04 chronodm

Although it doesn't set the environment correctly (it's always production).

dmolesUC avatar Apr 22 '16 18:04 dmolesUC

Please provide trace output of your full Capistrano run.

benlangfeld avatar Jun 05 '16 19:06 benlangfeld

For what it's worth:

$ bundle exec cap development whenever:update_crontab --trace
** Invoke development (first_time)
** Execute development
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke whenever:update_crontab (first_time)
** Execute whenever:update_crontab

dmolesUC avatar Jun 06 '16 16:06 dmolesUC

Please provide your full Capistrano config. Please also check that you have a server attached to Whenever's default role of :db. If this is not suitable, perhaps try overriding :whenever_roles. This is probably related to https://github.com/javan/whenever/pull/539.

benlangfeld avatar Jun 12 '16 17:06 benlangfeld

When cap development whenever:update_crontab does nothing

overriding :whenever_roles

# deploy.rb
set :whenever_roles, :all

solves the problem.

aminin avatar Dec 27 '16 17:12 aminin

Having a similar issue. When a server has a single role, it works, when a server has multiple roles, only the Whenever comments are added to the user's crontab:

server "xxx", :user => "yyy", :roles => %w[web app db]
server "xxx", :user => "yyy", :roles => %w[jobs]

set :whenever_roles, :all

schedule.rb:

every 2.minutes, :roles => [:web] do  # %w[web app db] does not work either 
  # Results in a crontab with just the Whenever comment 
end

every 12.hours, :roles => [:jobs] do
  # Works fine
end

sshaw avatar Feb 20 '21 19:02 sshaw