在我的服务器上,我有一个用于通过rake运行ruby脚本的cronjob,但是脚本没有被执行。我用2.1.2红宝石运行rvm,这是我的crontab:
SHELL=/bin/bash
PATH=/home/deployer/.rvm/gems/ruby-2.1.2/bin:/home/deployer/.rvm/gems/ruby- 2.1.2@global/bin:/home/deployer/.rvm/rubies/ruby-2.1.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/deployer/.rvm/bin:/home/deployer/.rvm/bin
*/1 * * * * cd /var/www/cars_crawler && /home/deployer/.rvm/gems/ruby-2.1.2/bin/rake >> /var/www/cars_crawler/cron.txt 2>&1
来自cronjob的错误是:
/home/deployer/.rvm/rubies/ruby-2.1.2/bin/ruby get_cars.rb
/home/deployer/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- nokogiri (LoadError)
当我手动运行rake命令时,不是通过crontab一切正常,但是从cronjob出现问题。我注意到这一行:/home/deployer/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/
我没有安装ruby 2.1.0。什么可能导致这个问题,我没有想法