Rails4にて
Capistrano3 + whenever で crontabの設定を行っています。

schedule.rbなどにて、環境ごとの設定を行いたいのですが、可能でしょうか?

# schedule.rb
set :output, 'log/crontab.log'

every :hour do
  rake "xxxxxxxx:delete_file", :environment => "staging"
  rake "xxxxxxxx:delete_file", :environment => "production"
end

# deploy.rb
set :whenever_environment, "#{fetch(:stage)}"
set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:stage)}" }

上記の様な書き方だと
cap staging deploy と cap production deployをした時に
以下の様なcrontabが出来上がってしまいます。

# Begin Whenever generated tasks for: xxxxxxxx_staging
    0 * * * * /bin/bash -l -c 'cd /home/xxx/www/html/xxxxxxxx/staging/releases/20150509011936 && RAILS_ENV=staging bundle exec rake xxxxx:delete_file --silent >> log/crontab.log 2>&1'
    0 * * * * /bin/bash -l -c 'cd /home/xxx/www/html/xxxxxxxx/staging/releases/20150509011936 && RAILS_ENV=production bundle exec rake xxxxx:delete_file --silent >> log/crontab.log 2>&1'

# End Whenever generated tasks for: xxxxxxxx_staging

# Begin Whenever generated tasks for: xxxxxxxx_production
    0 * * * * /bin/bash -l -c 'cd /home/xxx/www/html/xxxxxxxx/production/releases/20150509012426 && RAILS_ENV=staging bundle exec rake xxxxxxxx:delete_file --silent >> log/crontab.log 2>&1'
    0 * * * * /bin/bash -l -c 'cd /home/xxx/www/html/xxxxxxxx/production/releases/20150509012426 && RAILS_ENV=production bundle exec rake xxxxxxxx:delete_file --silent >> log/crontab.log 2>&1'

# End Whenever generated tasks for: xxxxxxxx_production

下記の様な結果が理想です。

# Begin Whenever generated tasks for: xxxxxxxx_staging
    0 * * * * /bin/bash -l -c 'cd /home/xxx/www/html/xxxxxxxx/staging/releases/20150509011936 && RAILS_ENV=staging bundle exec rake xxxxx:delete_file --silent >> log/crontab.log 2>&1'

# End Whenever generated tasks for: xxxxxxxx_staging

# Begin Whenever generated tasks for: xxxxxxxx_production
    0 * * * * /bin/bash -l -c 'cd /home/xxx/www/html/xxxxxxxx/production/releases/20150509012426 && RAILS_ENV=production bundle exec rake xxxxxxxx:delete_file --silent >> log/crontab.log 2>&1'

# End Whenever generated tasks for: xxxxxxxx_production