0

I have a shell script that is running under crontab that kicks back the error: "Ruby: Command not found" for the invocation of a Ruby script. I have no issue running this script when I invoke it through a terminal it is only when running under crontab that I have issues. Anyone have any thoughts?

EDIT: Using RVM, running RHEL.

3
  • How are you invoking the script from cron? Commented Jul 13, 2014 at 4:35
  • <cron timing info> <fullpath>/script.sh Commented Jul 13, 2014 at 4:36
  • Try dumping printenv to some file for both cases, while executing from crontab and directly executing it. My guess is crontab's env would not have the path to the actual Ruby executable. Commented Jul 13, 2014 at 4:39

1 Answer 1

4
/path/to/rvm 2.1 do /path/to/script.rb args...

because cron doesn't have your rvm settings, you need to start your script through rvm script (not rvm function) to explicitly choose a Ruby. (Obviously, replace 2.1 with whatever Ruby you want to execute under.)

Sign up to request clarification or add additional context in comments.

2 Comments

How much of the rvm path should I include? /home/<my username>/.rvm? or should I go further in to the version?
You need to find the rvm executable, wherever it was installed. Since I don't know how you installed rvm, I can't tell you exactly. For example, on the Ubuntu I administer, I installed it globally, so it sits in /usr/local/rvm/bin/rvm. On my Mac, it is in /Users/amadan/.rvm/bin/rvm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.