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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:35:32+00:00 2026-05-23T08:35:32+00:00

I am having a problem getting a Ruby script to work correctly when run

  • 0

I am having a problem getting a Ruby script to work correctly when run from a user’s crontab. It works okay when you run it from the terminal as that user. When run from crontab it fails on a system call.

Here is the script;

#!/usr/bin/ruby

require "net/http"
require "logger"
require "pp"

begin
        Dir.chdir("wca")
        time1 = Time.new
        filename = "updated" + "_" + time1.hour.to_s + "_" + time1.min.to_s + "_" + time1.sec.to_s + ".log"
        log = Logger.new(filename) 
        log.debug "===Checking For New Build"
        source = Net::HTTP.get('yr-qa-svr2', '/Wave/index.html')
        myFile = File.new("data/old.html","rb")
        old = myFile.read
        myFile.close

        if old != source then
            log.debug "   Server Version Changed, running tests"
            status = system("runWatir","webdriver.rb")
            if status then
                log.debug "   Command run correctly"
                myFile = File.new("data/old.html","w")
                myFile.puts source
                myFile.close
            else
                log.debug "   Failed to run command"
                log.debug "   Error number " + $?.to_s
            end
        else
            log.debug "   No Updates to Server Version"
        end
rescue Exception => e  
      print "Exception occured: " + e  + "\n"
      print e.backtrace
end 

When run from by crontab is produces this log;

    # Logfile created on Fri Jun 24 02:00:01 +0100 2011 by logger.rb/22285
    D, [2011-06-24T02:00:01.333921 #4409] DEBUG -- : ===Checking For New Build
    D, [2011-06-24T02:00:01.433632 #4409] DEBUG -- :    Server Version Changed, running tests
    D, [2011-06-24T02:00:01.462700 #4409] DEBUG -- :    Failed to run command
    D, [2011-06-24T02:00:01.462919 #4409] DEBUG -- :    Error number 32512

The command runWatir is a bash shell script located in the wca directory.

#!/bin/bash
rm logs/*.log
rm logs/*.png
export DATE=`date`
ruby -W0 $1|tee logs/$1.log
export RESULT=`grep assertions logs/$1.log`
export TIMED=`grep Finished logs/$1.log`
export BUILD=`cat logs/build.log`
ruby library/GenEmailMsg.rb "WATIR Results for $DATE" "Attached are the results from the WATIR automated test [$1] run with $BUILD..The results are $RESULT..$TIMED" logs/$1.log

What is my rookie mistake?

  • 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-23T08:35:32+00:00Added an answer on May 23, 2026 at 8:35 am

    cron jobs run as a different user with a different set of environment variables. Your PATH, rvm settings etc. will not be available unless you manually set them. I’m guessing you’re getting hit by one of these. The things to try are to make sure that your ruby version is the same in the cron job and your regular shell, that the users are the same and that the paths are the same.

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

Sidebar

Related Questions

I'm having a problem getting my data model to work correctly. I have the
I'm having a problem getting this functionality to work. Situation is: User Drags an
I am having a problem getting a list of fields from a query defined
I'm having a problem with getting a Ruby string substitution going. I'm writing a
Having a problem getting a TreeView control to display node images. The code below
I'm having a problem getting access to a database which lives on a remote
I am having a problem getting my project to link with the PhysX libraries
After having solved the problem of getting the editor to launch when there's a
Howdy, I'm having a bit of a problem getting my unit tests to pass.
I having a problem getting a ForeignKey to default to zero, it keeps telling

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.