error when running crontab
Added by Herbin TT over 8 years ago
Hi all,
I have intall redmine3.0.4 with git hosting and email_fectcher on Ubuntu 14.04
I have add a crontab looking like this
*/2 * * * * /opt/redmine/redmine-fetch-email-and-commit.sh
here is the content of redmine-fetch-email-and-commit.sh
#!/bin/bash
export GEM_PATH=/opt/redmine/.rvm/gems/ruby-2.1.4:/opt/redmine/.rvm/gems/ruby-2.1.4@global
export PATH=/opt/redmine/.rvm/gems/ruby-2.1.4/bin:/opt/redmine/.rvm/gems/ruby-2.1.4@global/bin:/opt/redmine/.rvm/rubies/ruby-2.1.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/redmine/.rvm/bin
cd /opt/redmine/redmine; /opt/redmine/redmine/bin/rake redmine:plugins:email_fetcher:fetch_all_emails RAILS_ENV=production
cd /opt/redmine/redmine; /opt/redmine/redmine/bin/rake redmine_git_hosting:fetch_changesets RAILS_ENV=production
exit;
The script work fine when run mannualy but when running with cron task, I recieve this error by mail
From redmine@lamdavm1 Thu Jun 16 10:16:02 2016
Return-Path: <redmine@lamdavm1>
X-Original-To: redmine
Delivered-To: redmine@lamdavm1
Received: by lamdavm1 (Postfix, from userid 109)
id 3090CE2675; Thu, 16 Jun 2016 10:16:02 +0100 (WAT)
From: root@lamdavm1 (Cron Daemon)
To: redmine@lamdavm1
Subject: Cron <redmine@lamdavm1> /opt/redmine/redmine-fetch-email-and-commit.sh
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/opt/redmine>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=redmine>
Message-Id: <20160616091602.3090CE2675@lamdavm1>
Date: Thu, 16 Jun 2016 10:16:02 +0100 (WAT)
/opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/source/git.rb:192:in `rescue in load_spec_files': https://github.com/jbox-web/grack.git (at fix_rails4@1bc51d8) is not yet checked out. Run `bundle install` first. (Bundler::GitError)
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/source/git.rb:189:in `load_spec_files'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/source/path.rb:95:in `local_specs'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/source/git.rb:160:in `specs'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/lazy_specification.rb:56:in `__materialize__'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/spec_set.rb:91:in `block in materialize'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in `map!'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in `materialize'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/definition.rb:140:in `specs'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/definition.rb:185:in `specs_for'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/definition.rb:174:in `requested_specs'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/environment.rb:19:in `requested_specs'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/runtime.rb:14:in `setup'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler.rb:95:in `setup'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/setup.rb:19:in `<top (required)>'
from /opt/redmine/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /opt/redmine/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /opt/redmine/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from /opt/redmine/redmine-3.0.4/config/boot.rb:4:in `<top (required)>'
from /opt/redmine/redmine/bin/rake:2:in `require_relative'
from /opt/redmine/redmine/bin/rake:2:in `<main>'
/opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/source/git.rb:192:in `rescue in load_spec_files': https://github.com/jbox-web/grack.git (at fix_rails4@1bc51d8) is not yet checked out. Run `bundle install` first. (Bundler::GitError)
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/source/git.rb:189:in `load_spec_files'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/source/path.rb:95:in `local_specs'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/source/git.rb:160:in `specs'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/lazy_specification.rb:56:in `__materialize__'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/spec_set.rb:91:in `block in materialize'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in `map!'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/spec_set.rb:88:in `materialize'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/definition.rb:140:in `specs'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/definition.rb:185:in `specs_for'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/definition.rb:174:in `requested_specs'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/environment.rb:19:in `requested_specs'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/runtime.rb:14:in `setup'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler.rb:95:in `setup'
from /opt/redmine/.rvm/gems/ruby-2.1.4/gems/bundler-1.12.5/lib/bundler/setup.rb:19:in `<top (required)>'
from /opt/redmine/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /opt/redmine/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /opt/redmine/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from /opt/redmine/redmine-3.0.4/config/boot.rb:4:in `<top (required)>'
from /opt/redmine/redmine/bin/rake:2:in `require_relative'
from /opt/redmine/redmine/bin/rake:2:in `<main>'
Please I Need your help!
Replies (1)
RE: error when running crontab - Added by Herbin TT over 8 years ago
I have found the issue
When running with cron, it is not the same environnement when running mannualy
enter this command printenv
PATH=/opt/redmine/.rvm/gems/ruby-2.1.4/bin:/opt/redmine/.rvm/gems/ruby-2.1.4@global/bin:/opt/redmine/.rvm/rubies/ruby-2.1.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/redmine/.rvm/bin
rvm_loaded_flag=1
PWD=/opt/redmine
LANG=fr_FR.UTF-8
_system_arch=x86_64
_system_version=14.04
rvm_version=1.27.0 (latest)
SHLVL=1
HOME=/opt/redmine
LOGNAME=redmine
GEM_PATH=/opt/redmine/.rvm/gems/ruby-2.1.4:/opt/redmine/.rvm/gems/ruby-2.1.4@global
XDG_RUNTIME_DIR=/run/user/1000
RUBY_VERSION=ruby-2.1.4
copy all variable and put it in your shell for exemple
export PATH=/opt/redmine/.rvm/gems/ruby-2.1.4/bin:/opt/redmine/.rvm/gems/ruby-2.1.4@global/bin:/opt/redmine/.rvm/rubies/ruby-2.1.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/redmine/.rvm/bin
This solve problem and now I m able to fetch mails and new commits
Thanks