Capistrano deploy, sporadic duplicate cronjob entries
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
We are seeing this behavior occurring with every cap deploy.
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:
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.
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.
No "official" way to fix this ?
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