2

It looks like my schedule.rb file contents are being appeneded to my crontab each time I deploy via capistrano. The only difference being the release directory

I seem to have this in my crontab repeated for probably as many times as I have deployed my app now:

# Begin Whenever generated tasks for: /var/www/myapp/releases/20170324043318/config/schedule.rb
0 2 1 * * /bin/bash -l -c 'cd /var/www/myapp/releases/20170324043318 && RAILS_ENV=production bundle exec rake generate_timeslots --silent >> /var/www/myapp/releases/20170324043318/log/cron.log 2>&1'

0 0,12 * * * /bin/bash -l -c 'cd /var/www/csmschedule/releases/20170324043318 && RAILS_ENV=production bundle exec rake send_backup_email --silent >> /var/www/myapp/releases/20170324043318/log/cron.log 2>&1'

# End Whenever generated tasks for: /var/www/myapp/releases/20170324043318/config/schedule.rb

This is the output of my capistrano deploy:

whenever:update_crontab
      01 ~/.rvm/bin/rvm 2.3.3 do bundle exec whenever --update-crontab  --set environment=production --roles=db
      01 [write] crontab file updated
      01
    ✔ 01 myuser@123.456.78.9 0.913s

I see the --update-crontab option is being used in my capistrano deploy. I'm not setting that explicitly anywhere. Is there a way to turn that off so that it overwrites my crontab? Or am i misunderstanding this flag?

Capfile

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/passenger'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'whenever/capistrano'
require 'airbrake/capistrano3'
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

Gemfile.lock shows whenever version 0.9.7

I've successfully used whenever without this issue when my app and db are on the server server, but this is the first time i'm trying to use whenever with the db being on a different server than my app server.

Any ideas how to make it so my crontab gets overwritten instead of appended to?

I'm running on Ubuntu 16.04.

Catfish
  • 18,876
  • 54
  • 209
  • 353

1 Answers1

0

I manually deleted all the lines in my crontab via $ crontab -e and then redeployed my app a few times and it seems to be correctly overwriting my crontab on each deploy now.

Catfish
  • 18,876
  • 54
  • 209
  • 353
  • This is OK until you add another schedule. Then you will need to edit via `crontab -e` again. – Askar Dec 23 '19 at 07:54