Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6714371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:29:18+00:00 2026-05-26T08:29:18+00:00

I have one job in schedule.rb : set :output, File.expand_path(‘../log/whenever.log’, __FILE__) set :job_template, bash

  • 0

I have one job in schedule.rb:

set :output, File.expand_path('../log/whenever.log', __FILE__)
set :job_template, "bash -l -c 'source ~/.bashrc ; :job'"

every 1.day, :at => '12:01 am' do
  runner "MyModel.do_something"
end

In my staging deployment (bash) script I have this line to write to cron:

ssh $SERVER "cd $DEPLOY_TO && whenever --set environment=staging -w"

And this line in the production deployment script:

ssh $SERVER "cd $DEPLOY_TO && whenever --set environment=production -w"

This works fine and creates the job when I deploy either environment. The problem is that whenever sees them both as one job so it gets overwritten by whichever environment was last deployed:

# Begin Whenever generated tasks for: /Users/simon/apps/myapp/staging/config/schedule.rb
1 0 * * * bash -l -c 'source ~/.bashrc ; cd /Users/simon/apps/myapp/staging && script/rails runner -e staging 'MyModel.do_something' >> /Users/simon/apps/myapp/staging/log/whenever.log 2>&1'

# End Whenever generated tasks for: /Users/simon/apps/myapp/staging/config/schedule.rb

and…

# Begin Whenever generated tasks for: /Users/simon/apps/myapp/production/config/schedule.rb
1 0 * * * bash -l -c 'source ~/.bashrc ; cd /Users/simon/apps/myapp/production && script/rails runner -e production 'MyModel.do_something' >> /Users/simon/apps/myapp/production/log/whenever.log 2>&1'

# End Whenever generated tasks for: /Users/simon/apps/myapp/production/config/schedule.rb

What’s a sensible way to add the same cron job for two separate environments on the same server?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:29:18+00:00Added an answer on May 26, 2026 at 8:29 am

    You can namespace your whenever tasks by using something similar to the following:

    # Whenever
    set :whenever_environment, defer { stage }
    set :whenever_identifier, defer { "#{application}-#{stage}" }
    require "whenever/capistrano"
    

    In the above example, stage is the variable that contains the environment. Change it to whatever you are using.

    The Capistrano integration section at https://github.com/javan/whenever goes into a bit more detail if you need it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question, I think. I have org.springframework.scheduling.quartz.CronTriggerBean triggering one job once a day. Because
I have a simple map/reduce job that scans one hbase table, and modifies another
i have one csv file which contains library group and it's data... group consider
I have one Sqlite Database file. I want to share my sqlite database between
I have one file example1.cpp with the main function. This file must have #include
I have one file one.php <?php //just a php function doen't have to do
I have first time installed th cron job for magento. THere is one module
I have a Hudson job that launches a .bat script file that itself launches
I am working on a Windows service which needs to schedule tasks whenever one
have one time consuming step that flattens a bunch of files. basically i'd like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.