Welcome Guest | Login

error running a ruby file with cron

Hi,

I need to run a .rb file for maintenance purposes in my application, and I am trying to run the following command in the cron:

cd /home/username/app_name/current && ruby script/runner script/script_file.rb

and I get the following error: /bin/sh: ruby: command not found

I have alrready read a couple of posts, so I included the #!/usr/local/bin/ruby  shebang line at the top in the runner script but its still not working.

What can I do?

2008-04-07 07:15 PM

Just for clarification purposes. I have alrready run this command on the terminal, and it works without a problem. Also I have current at the end of the path because i am using capistrano to deploy.

2008-04-07 07:17 PM

Hi - Please try using the command as

cd /home/username/app_name/current && /usr/local/bin/ruby script/runner script/script_file.rb

2008-04-07 08:23 PM

HostingRails Support
Hi, i tried the command and now I am getting the following error:

Access denied for user 'root'@'localhost' (using password: NO) (Mysql::Error)

I think the script is trying to run on the development database. How cai I set it to run on production?

2008-04-07 09:05 PM


The script is now working when I executed it from command line.
I just configured another section for development database in your database.yml file with your production database. Please verify it now in your database.yml file.

2008-04-07 10:26 PM

thanks its working now!

But could you explain to me what you did for it to work?

thanks.

2008-04-07 11:14 PM

I replaced the database.yml file with a fresh new one and added the current entries present there. Please verify it in your account. The script seems to be taking the development database section so I put the same database and login details of your production database under "development:" section. You may need to maintain both production and development entries as it is now so your app and maintenance script would work fine.

2008-04-08 12:10 AM


Hello Guest! In order to post you must be an active client with us, please log in or sign up.