whenever icon indicating copy to clipboard operation
whenever copied to clipboard

Capistrano deploy, sporadic duplicate cronjob entries

Open giulioprovasi opened this issue 8 years ago • 6 comments

Hello,

I am maintaining an application using whenever and, sometimes during deploy with capistrano, I end up with a crontab with duplicates entries, is this a known issue ? I found nothing on the tracker.

Here are the capistrano logs about update_crontab:

02:13 whenever:update_crontab
      01 /usr/local/rvm/bin/rvm 2.2.2@app do bundle exec whenever --update-crontab app --set environment=production --roles=worker
      01 *** schedule.rb, cron loaded
      01 [write] crontab file updated
    ✔ 01 app@xxx 1.295s

giulioprovasi avatar Dec 12 '17 15:12 giulioprovasi

We are seeing this behavior occurring with every cap deploy.

josephbridgwaterrowe avatar Dec 21 '17 18:12 josephbridgwaterrowe

So, on further investigation our problem was resolved by adding the application to the deploy.rb file (it was in there previously, but I had removed it since I thought it was superfluous) :smile:

josephbridgwaterrowe avatar Dec 21 '17 18:12 josephbridgwaterrowe

Just want to confirm that I am also seeing this behaviour - had an application with duplicate entries in the crontab. Re-deploying didn't fix this issue - the multiple entries stayed. The only way to fix this was to manually remove the duplicate.

zjullion avatar Feb 06 '18 18:02 zjullion

One way to fix this issue for re-deploys would be to modify https://github.com/javan/whenever/blob/master/lib/whenever/command_line.rb#updated_crontab such that multiple 'identifier blocks' can be found in the crontab and all removed together.

zjullion avatar Feb 06 '18 21:02 zjullion

No "official" way to fix this ?

Marinlemaignan avatar Mar 07 '19 13:03 Marinlemaignan

whenver uses an identifier to sync the crontab. that identifier is by default the :application setting. so be sure to have that set, as mentioned above. you can set a different identifier with set :whenever_identifier, "foo-bar".

beware: the moment you change the identifier, you'll end up with one duplicated crontab entry. the one with the old identifier and one with the new one.

this is how the defaults are set: https://github.com/javan/whenever/blob/b205bcdea33629a2b902af4df2097d3a92ba21f9/lib/whenever/capistrano/v3/tasks/whenever.rake#L44-L55

glaszig avatar Nov 26 '19 20:11 glaszig