WebFaction
Community site: login faq

I've got a number of PHP scripts running just fine in my cron job file using curl and the URL. Now I'd like to run a ruby script twice a month as a cron job, but it's not working. Here's what the command looks like in the crontab -l

08 03 01,16 * * ruby /home/myusername/webapps/mydirectory/mysubdirectory/name_of_script.rb

The script is supposed to write some information to a file in the same directory. When I run the command manually

ruby /home/myusername/webapps/mydirectory/mysubdirectory/name_of_script.rb

it works fine.

Thanks for any suggestions.

asked 16 Nov '12, 10:25

phpdiva
1316
accept rate: 0%


First, try using the full path to ruby in your cron job, eg /usr/local/bin/ruby instead of just ruby.

If that doesn't work, then try adding some output redirection to your cron job, like this:

08 03 01,16 * * /usr/local/bin/ruby /home/myusername/webapps/mydirectory/mysubdirectory/name_of_script.rb >> ~/logs/user/cron.log 2>&1

Then you can check ~/logs/user/cron.log for errors that might indicate what the problem is.

Hope that helps!

permanent link

answered 16 Nov '12, 17:32

seanf
12.2k41836
accept rate: 37%

Thanks. Tried that, tried adding PATH and GEM_HOME variables to my crontab, tried running the Ruby script from a shell script ... nothing works from the crontab and I'm not even getting anything in a ~/logs/user/cron.log file. Stumped.

(19 Nov '12, 14:57) phpdiva

Submit a support ticket so we can take a closer look at the script and server logs.

(19 Nov '12, 17:20) johns
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:

×81
×81
×50
×17

question asked: 16 Nov '12, 10:25

question was seen: 5,679 times

last updated: 19 Nov '12, 17:20

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