WebFaction
Community site: login faq

Hi,

I have a rails app and I am managing the cron jobs using the whenever gem.

Following is the output of the command "crontab -l"

# Begin Whenever generated tasks for: laq

0 * * * * cd /home/myaccount/webapps/app/releases/20140724102945 && RAILS_ENV=production GEM_HOME=/home/myaccount/webapps/app/gems PATH=/home/myaccount/webapps/app/bin:$PATH bundle exec rake tweet:quote -s

# End Whenever generated tasks for: laq

When I run this job through the command line it works as expected, but it is not running through cron.

How to get this working on webfaction?

asked 24 Jul '14, 13:33

brahmadpk
314
accept rate: 0%

edited 24 Jul '14, 18:31

seanf
12.2k41836

The first step in solving this is to determine what the actual failure is. The simplest way to do that is to add ">> $HOME/logs/user/cron.log 2>&1 " to the end of the cron job, and then check ~/logs/user/cron.log after the next run.

Once you know the actual error, you'll be in a better position to solve the problem. If you still need assistance at that point, then please edit your question to include the error message, and we'll go from there.

(24 Jul '14, 18:34) seanf

@seanf I did what you mentioned in the comment. As per the log file the error is

/usr/bin/env: ruby2.0: No such file or directory

How to take care of this?

(24 Jul '14, 19:12) brahmadpk

See my answer below :)

(24 Jul '14, 21:08) seanf

Cron jobs run with a different PATH compared to interactive shell sessions, so you need to ensure that /usr/local/bin (where ruby2.0 is) is on the PATH used by your cron job. For example:

0 * * * * cd /home/myaccount/webapps/app/releases/20140724102945 && RAILS_ENV=production GEM_HOME=/home/myaccount/webapps/app/gems PATH=/home/myaccount/webapps/app/bin:/usr/local/bin:$PATH bundle exec rake tweet:quote -s >> $HOME/logs/user/cron.log 2>&1

Hope that helps!

permanent link

answered 24 Jul '14, 21:07

seanf
12.2k41836
accept rate: 37%

Thanks. It worked.

(25 Jul '14, 06:15) brahmadpk
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

question asked: 24 Jul '14, 13:33

question was seen: 6,547 times

last updated: 25 Jul '14, 06:15

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