WebFaction
Community site: login faq

Here's my cron task:

0,30 * * /home/USERNAME/webapps/APPNAME/RAILS-FOLDER/script/rails runner -e production /home/USERNAME/webapps/APPNAME/RAILS-FOLDER/script-name.rb

It fails with the following error:

/usr/bin/env: ruby: No such file or directory

OK, so ruby does not exist in the environment. I suspect my path. A quick search of StackOverflow suggests adding the path to the ruby executable to $PATH. So I modified ~/.profile by adding this line:

export PATH=/usr/local/bin:$PATH

Now nothing is happening. I was getting error messages by email (using MAILTO=[redacted]@gmail.com at the head of my crontab) but I'm no longer getting them. I cannot tell if cron is even running after my changes. BTW, the email messages I did receive lacked a valid "From", which makes me wonder if gmail is just deleting them. How else can I log what happens when my cron task exectues?

asked 10 Feb '11, 00:20

TimInCali
111
accept rate: 0%


This is indeed a PATH-related issue. However, rather than using a ~/.profile file, we normally recommend simply using the full path to the executable; for example:

0 * * * * /usr/local/bin/ruby /home/USERNAME/webapps/APPNAME/RAILS-FOLDER/script/rails

For reference, here is cron's entire environment:

# cron's environment:
USER=<username>
SHELL=/bin/sh
PATH=/usr/bin:/bin
PWD=/home/<username>
SHLVL=1
HOME=/home/<username>
LOGNAME=<username>

Another thing we notice is that your cron job does not appear to use the correct number of time specifiers at the beginning; i.e, you are using:

0,30 * *

But this should probably be:

0,30 * * * *

As for logging, sending emails will general work if the crontab fails, but won't have an effect in the case of a syntax error. You can also submit a support ticket and we can provide some relevant lines from the cron log file.

permanent link

answered 10 Feb '11, 00:40

ryans ♦♦
5.0k93360
accept rate: 43%

Thanks, Ryan. I prepended /usr/local/bin/ruby like you suggested, but it still doesn't work.

I'll open a support ticket and post a relevant response to this issue.

BTW, my crontab does have five time specifiers. I think a few were removed from my post by markdown.

(10 Feb '11, 17:53) TimInCali

Hi,

We'll take a look at the ticket and get back to you.

(10 Feb '11, 18:21) klynton
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×108
×81
×81
×19

question asked: 10 Feb '11, 00:20

question was seen: 5,650 times

last updated: 10 Feb '11, 18:21

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM