仅用于cron:/ usr / bin / env:ruby_executable_hooks:无此类文件或目录 [英] Only with cron: /usr/bin/env: ruby_executable_hooks: No such file or directory

查看:119
本文介绍了仅用于cron:/ usr / bin / env:ruby_executable_hooks:无此类文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个perl脚本,该脚本使用system()调用shell命令,该命令使用ruby_executable_hooks。

I have a perl script that uses system() to call a shell command, which uses ruby_executable_hooks.

当我从命令行运行此脚本时,它会完美执行

When I run this script from the command line it executes flawlessly.

但是,当它从cron作业运行时,出现两个错误之一:
A)如果我不使用chdir()即。工作目录是/ home / foobar

However when it runs from a cron job, I get one of two errors: A) if I do not chdir() ie. working dir is /home/foobar

/usr/bin/env: ruby_executable_hooks: No such file or directory

B)如果我chdir( [doc root] / cgi-bin)

B) if I chdir( "[doc root]/cgi-bin" )

/usr/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem twurl (>= 0) (Gem::LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
from /home/foobar/.rvm/gems/ruby-1.9.3-p551/bin/twurl:22
from /home/foobar/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/gems/1.9.1/bin/ruby_executable_hooks:15

从cron运行时无法找到某些文件的原因可能是什么?

What might be the reason it cannot find certain files when run from cron?

推荐答案

我在这里找到了答案:
https://unix.stackexchange .com / questions / 27289 / how-can-我运行带有现有环境变量的cron命令

I found the answer here: https://unix.stackexchange.com/questions/27289/how-can-i-run-a-cron-command-with-existing-environmental-variables

具体来说,我只是输入。 $ HOME / .profile;放在cron命令前面,例如:

Specifically, I just put ". $HOME/.profile;" in front of the cron command like so:

0 5 * * *。$ HOME / .profile; / path / to / command /

0 5 * * * . $HOME/.profile; /path/to/command/to/run

谢谢大家让我走上了正轨。

Thank you all for putting me on the right track.

这篇关于仅用于cron:/ usr / bin / env:ruby_executable_hooks:无此类文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆