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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:05:45+00:00 2026-05-11T07:05:45+00:00

I have a Rails script that I would like to run daily. I know

  • 0

I have a Rails script that I would like to run daily. I know there are many approaches, and that a cron’d script/runner approach is frowned upon by some, but it seems to meet my needs.

However, my script is not getting executed as scheduled.

My application lives at /data/myapp/current, and the script is in script/myscript.rb. I can run it manually without problem as root with:

/data/myapp/current/script/runner -e production /data/myapp/current/script/myscript.rb 

When I do that, the special log file (log/myscript.log) gets logged to as expected:

Tue Mar 03 13:16:00 -0500 2009 Starting to execute script... ... Tue Mar 03 13:19:08 -0500 2009 Finished executing script in 188.075028 seconds 

I have it set to run with cron every morning at 4 am. root‘s crontab:

$ crontab -l 0 4 * * * /data/myapp/current/script/runner -e production /data/myapp/current/script/myscript.rb 

In fact, it looks like it’s tried to run as recently as this morning!

$ tail -100 /var/log/cron ... Mar  2 04:00:01 hostname crond[8894]: (root) CMD (/data/myapp/current/script/runner -e production /data/myapp/current/script/myscript.rb) ... Mar  3 04:00:01 hostname crond[22398]: (root) CMD (/data/myapp/current/script/runner -e production /data/myapp/current/script/myscript.rb) ... 

However, there is no entry in my log file, and the data that it should update has not been getting updated. The log file permissions (as a test) were even set to globally writable:

$ ls -lh total 19M ... -rw-rw-rw- 1 myuser apps 7.4K Mar  3 13:19 myscript.log ... 

I am running on CentOS 5.

So my questions are…

  1. Where else can I look for information to debug this?
  2. Could this be a SELinux issue? Is there a security context that I could set or change that might resolve this error?

Thank you!

Update

Thank you to Paul and Luke both. It did turn out to be an environment issue, and capturing the stderr to a log file enabled me to find the error.

$ cat cron.log  /usr/bin/env: ruby: No such file or directory  $ head /data/myapp/current/script/runner  #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner' 

Adding the specific Ruby executable to the command did the trick:

$ crontab -l 0 4 * * * /usr/local/bin/ruby /data/myapp/current/script/runner -e production /data/myapp/current/script/myscript.rb >> /data/myapp/current/log/cron.log 2>&1 
  • 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. 2026-05-11T07:05:46+00:00Added an answer on May 11, 2026 at 7:05 am

    By default cron mails its output to the user who ran it. You could look there.

    It’s very useful to redirect the output of scripts run by cron so that you can look at the results in a log file instead of some random user’s local mail on the server.

    Here’s how you would redirect stdout and stderr to a log file:

    cd /home/deploy/your_app/current; script/runner -e production ./script/my_cron_job.rb >> /home/deploy/your_app/current/log/my_file.log 2>&1 

    The >> redirect stdout to a file, and and the 2>&1 redirects stderr to stdout so any error messages will be logged as well.

    Having done this, you will be able to examine the error messages to see what’s really going on.

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

Sidebar

Related Questions

I have a Ruby script in my Rails app that I use to load
I have a rails application running on a Linux server. I would like to
I have a rails model that looks something like this: class Recipe < ActiveRecord::Base
I have a Rails log that looks like this Started GET [path-omitted] for 166.137.138.210
I have a rails app that I have serving up XML on an infrequent
I have a Rails app that I have successfully tested with Mongrel and Webkit.
Is there an easy way to have a rails action load up an external
I have an library of scripts I would like to implement on the client
I would like to know how to parse a YAML file with the following
From a practical and best practices perspective, should rails models that have HABTM association

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.