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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:36:22+00:00 2026-06-02T00:36:22+00:00

Using Whenever 0.7.3, Rails 3.2.2, Ruby 1.9.3, Passenger 3.0.11 on a CentOS 5.6 server

  • 0

Using Whenever 0.7.3, Rails 3.2.2, Ruby 1.9.3, Passenger 3.0.11 on a CentOS 5.6 server (I’m not using rvm). The problem is that the cron jobs created by whenever are clearly executed, I can see them in the Cron log, however they don’t actually execute the Rails code. If I copy the cron code and paste it in the terminal it works as expected and does.

The code to be executed:

class SomeModel < ActiveRecord::Base

  #Delete all items that haven't been updated for 2 hours or more
  def self.cron_job
    SomeModel.destroy_all(updated_at < ?", 2.hours.ago])
  end
end

The schedule.rb:

set :output, "/var/log/cron"

every 1.day, :at => '4:45 am' do
  runner "SomeModel.cron_job"
end

Which generated the following cron (output crontab -l):

# Begin Whenever generated tasks for: site_name
45 4 * * * /bin/bash -l -c 'cd /home/user/domains/site_name && script/rails runner -e production '\''SomeModel.cron_job'\'' >> /var/log/cron 2>&1'
# End Whenever generated tasks for: site_name

If I check the following morning I find this in the cron log:

Apr 14 04:45:01 node1 crond[9155]: (root) CMD (/bin/bash -l -c 'cd /home/user/domains/site_name && script/rails runner -e production '\''SomeModel.cron_job'\'' >> /var/log/cron 2>&1')

However the items that should have been deleted are still in the database. If I copy the code cron is supposed to execute (/bin/bash -l -c ‘cd … 2>&1’ and execute it from the terminal then the items are removed as expected.

Also when I execute the code manually from the terminal there are no errors, in the cron log i see the following:

from script/rails:5:in 'require'
from script/rails:5
from script/rails:5:in 'require'
from script/rails:5

At moments where several cron jobs are executed this “error(?)” is printed only once in the log.

Is there a difference between executing something from a cronjob or entering the code in the terminal? Why can there be a difference and how do I ensure that it also works from the cronjob? Also is the log output supposed to be an error, it’s not telling me much unfortunately.

  • 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-06-02T00:36:24+00:00Added an answer on June 2, 2026 at 12:36 am

    Ok solved it now. The problem was that I had both a Ruby in /usr/bin and a Ruby in /usr/local/bin.

    I’ve deleted the ruby in /usr/bin and added the right path variable (PATH=”/usr/local/bin:/usr/bin:/bin”) to the crontab. Everything working as expected now.

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

Sidebar

Related Questions

I'm using Rails 3.2 (not a ruby on rails question) and coming close to
I have been using whenever to easily configure soem cron jobs I need to
I am using an iframe in my project and it seems that whenever it
Using Ruby on Rails 3, I have a page with a list of comments
My Ruby on Rails app is using LivePipe Modals. ( http://livepipe.net/ ) Everything has
I am using the client side validations gem (v3.1.0) with Rails 3.1.1 and whenever
I originally configured my computer with rails, ruby and rvm. Afterwards, I downloaded mysql,
I have a requirement in my ruby code.I'm using ruby 1.9.2 and rails 3.0.
I am using Blueprint CSS with Rails. Whenever I use a a tag with
I am new to Ruby and Rails, and whenever I attempt to generate my

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.