LoginSignup
3
2

More than 5 years have passed since last update.

cron.dailyで起動するscriptで、gemが見つからないときの対処方 (rvmの場合)

Last updated at Posted at 2015-12-11

cron.dailyのlogwatchでgemが見つからない

logwatchでruby gemを使うスクリプトを起動するとき、gemが見つからないというエラーで困ったときの話。
OSは、CentOS 6.6です。

※このサーバではrvmでrubyをインストールしています。

/usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- pg_query (LoadError)
     from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
     from /etc/logwatch/scripts/services/postgresql:6:in `<main>'

対処方

環境変数GEM_HOMEを、/etc/crontabに追記したり、/etc/cron.daily/0logwatchに追記したりしたんですが、うまくいきませんでした。

/etc/cron.daily/0logwatchのlogwatch起動部分を直接書き換えると、うまくいきました。

bash -c '. /usr/local/rvm/scripts/rvm && /usr/sbin/logwatch --output mail'

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2