0

Background - the system has two different versions of ruby installed. I need to use the latest version to run this monitor script i've created

This is my crontab line:

0 * * * * /usr/local/rvm/rubies/ruby-2.2.1/bin/ruby /home/nexpose/ruby/console_monitor.rb

When I run this:

/usr/local/rvm/rubies/ruby-2.2.1/bin/ruby /home/nexpose/ruby/console_monitor.rb

it works as expected and even sends me an email as designed

When I check syslog I don't see much. I see that its being executed but no errors shown..

 # which ruby
 /usr/local/rvm/rubies/ruby-2.2.1/bin/ruby
 # ruby -v
 ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]

Does this have to do with my PATH configuration? I thought I was bypassing this by pointing directly to the ruby binary?

0

Remember that cron jobs have minimal environment settings. They do not have the settings you see in an interactive shell. Cron does not execute ~/.login, ~/.bashrc, etc.

To see errors from a cron job, I find it most convenient to redirect STDOUT and STDERR to a file. e.g append > /tmp/cron.out 2>&1 to the crontab entry. Otherwise your system might package the output into an email message to the owner of the crontab.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.