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 6758549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:48:26+00:00 2026-05-26T13:48:26+00:00

In schedule.rb file, the statement: require #{RAILS_ROOT}/config/environment.rb every 10 10 2 * * *

  • 0

In schedule.rb file, the statement:

require "#{RAILS_ROOT}/config/environment.rb"

 every "10 10 2 * * *" do
      command "mysqldump -u #{@db_username} -p#{@db_password} --single-transaction #{@db_name} > #{@backup_Path}/#{@db_name}.sql 2> log/error_crontab.log"
 end

When i try to execute the whenever cmd from terminal, getting the following error:

 config/schedule.rb:48:in `initialize': uninitialized constant Whenever::JobList::RAILS_ROOT (NameError)
    from /usr/local/lib/ruby/gems/1.9.1/gems/whenever-0.7.0/lib/whenever/job_list.rb:19:in `instance_eval'
    from /usr/local/lib/ruby/gems/1.9.1/gems/whenever-0.7.0/lib/whenever/job_list.rb:19:in `initialize'
    from /usr/local/lib/ruby/gems/1.9.1/gems/whenever-0.7.0/lib/whenever.rb:16:in `new'
    from /usr/local/lib/ruby/gems/1.9.1/gems/whenever-0.7.0/lib/whenever.rb:16:in `cron'
    from /usr/local/lib/ruby/gems/1.9.1/gems/whenever-0.7.0/lib/whenever/command_line.rb:40:in `run'
    from /usr/local/lib/ruby/gems/1.9.1/gems/whenever-0.7.0/lib/whenever/command_line.rb:7:in `execute'
    from /usr/local/lib/ruby/gems/1.9.1/gems/whenever-0.7.0/bin/whenever:38:in `<top (required)>'
    from /usr/local/bin/whenever:19:in `load'
    from /usr/local/bin/whenever:19:in `<main>'

i am using the require statement to get the dynamic values from the form to schedule the job. Please help to solve this issue?

Note: i have seen the following stackoverflow queries:
How to detect Rails environment inside whenever

Following this thread to get dynamic values, but facing problem with require statement.
Rails – Whenever gem – Dynamic values

Ruby/Rails – Whenever gem – Loop cron tasks

config file in schedule.rb with Rails Whenever gem?

  • 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-26T13:48:27+00:00Added an answer on May 26, 2026 at 1:48 pm

    Whenever doesn’t require or depend on Rails at all, so when it runs, RAILS_ROOT is not defined, however because whenever’s schedule.rb is generally kept in /config/schedule.rb, we can make an assumption that it is in a rails project, and set our own RAILS_ROOT like this:

    # in schedule.rb
    RAILS_ROOT = File.dirname(__FILE__) + '/..'
    

    Edit: in the case that you actually need Rails loaded, do this:

    # in schedule.rb
    # this will require config/environment and load your entire rails environment
    require File.expand_path(File.dirname(__FILE__) + "/environment")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have setup my schedule.rb file as follows. set :cron_log, /log/cron_log.log if Rails.env.development? every
I am doing backup schedule every day. If any backup file is not created
I'm trying to schedule a repeating event to run every minute in Python 3.
How do I schedule SSIS to automatically execute a package from a file at
I have a table which holds flight schedule data. Every schedule have an effective_from
So I have an R file that I would like to schedule to run
If I schedule print Hello World!; to run every hour with crontab, where will
I have one job in schedule.rb : set :output, File.expand_path('../log/whenever.log', __FILE__) set :job_template, bash
I got an schedule in an plist-file, reading the events (read: times) is not
I have created a php file I want to run every day at 8am

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.