The whenever gem has worked great for me, for years now, in production. My project is now big enough to need a staging environment, and Capistrano has made this effortless. However, the one thing that I cannot sort out is preventing the whenever gem from writing cron entries on the staging server.
I've been searching for an answer for literally weeks, off and on, among doing other things, and I've tried about 6 different hacks from blogs and other SO posts. I've created an issue on GitHub about the one thing that the documentation suggests: "namespacing" the schedule.rb file. Nothing about my interpretation of that statement works. And all the references here on SO seem to be about the gem NOT writing crontab entries. My problem is that it writes too many!
Rather than going down the rabbit hole about that particular issue, I thought maybe I would try asking the question directly. Surely, people are doing this. It seems like an obvious and basic thing to want from such a process, e.g., to tie jobs to various environments. But, like I said, everything I've tried has failed, and I still wind up with only-production-appropriate crontab entries in staging.
What's the cleanest way of implementing environment-specific jobs, that works?
We pass an environment variable to segment which jobs run on which server environment.