Project

General

Profile

Receive E-Mails via cronjob on Debian

Added by Matthias Fischer about 11 years ago

Hi,

i have a big problem to receive incoming mails to create new tickets via cronjob.
using the commands in the shell works fine. i tried the command:

* * * * * rake -f /path/to/redmine/appdir/Rakefile redmine:email:receive_imap RAILS_ENV="production" host=imap.foo.bar username=redmine@somenet.foo password=xxx

which is mentioned @ the wiki. in my systemlog i can see the exit code 127, which means that the command is not found i think. ok rake seems to be the problem.
In http://www.redmine.org/boards/2/topics/6271 there is a shell-script which is called by a cronjob.

#!/bin/bash
export PATH=$PATH:/usr/local/rubygems/bin:/usr/local/rubygems/gems/bin
export RUBYLIB=/usr/local/rubygems/lib
export GEM_HOME=/usr/local/rubygems/gems
cd /home/htdocs/redmine
/usr/local/bin/rake --trace redmine:email:receive_imap RAILS_ENV="production" host=mail.server.tld username={username} password={password} folder=INBOX tracker=Sonstiges status=Neu priority=Normal move_on_success=INBOX.read move_on_failure=INBOX.failed allow_override=project,tracker,priority,status

There are PATH, RUBYLIB and the GEM_HOME Variables that should fix this problem right? iam a newbie and have no idea about ruby and the gems especially about the different locations. what paths do i have to fill in there?

gem rev has the following output:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.0
  - RUBY VERSION: 2.0.0 (2013-02-24 patchlevel 0) [i686-linux]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.0.0
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/2.0.0
     - /root/.gem/ruby/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

i cant find paths like /rubygems/lib oder /rubygems/gems in my installation :(

Do you have any idea?

My installation:

Environment:
  Redmine version                          2.3.0.stable
  Ruby version                             2.0.0 (i686-linux)
  Rails version                            3.2.13
  Environment                              production
  Database adapter                         Mysql2
Redmine plugins:
  due_date_reminder                        0.3.2
  project_overview                         1.1.0
  redmine_dmsf                             1.4.5p1 stable
  redmine_issue_checklist                  2.0.5
  redmine_issue_templates                  0.0.5
  stuff_to_do_plugin                       0.4.1

Thanks


Replies (1)

RE: Receive E-Mails via cronjob on Debian - Added by Matthias Fischer about 11 years ago

i changed my shell-script to

export PATH=$PATH:/root/.gem/ruby/2.0.0:/usr/local/lib/ruby/gems/2.0.0
export RUBYLIB=/usr/local/lib/ruby
export GEM_HOME=/usr/local/lib/ruby/gems/2.0.0
cd /opt/redmine
/usr/local/bin rake -f /opt/redmine/Rakefile redmine:email:receive_imap RAILS_ENV="production" host=192.168.1.3 username=redmine password=redmine project=technik-intern tracker="nicht zugeordnet" allow_override=tracker,priority unknown_user=accept

and added
2>&1 |/usr/bin/logger -t redmine

to my cronjob. now the syslog shows a permission issue but i have no idea which permission is denied.
redmine: /root/mail.sh: 6: /usr/local/bin: Permission denied
    (1-1/1)