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 |
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:
For reference, here is cron's entire environment:
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:
But this should probably be:
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. answered 10 Feb '11, 00:40 ryans ♦♦ 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
|