Search code examples
crontaskrakeredminejobs

Redmine Cron Job Issue


I must set a Cron Job on Redmine to automatically manage IMAP fetching. I try to supply as many infos as I can about my environment:

Redmine version               3.2.0.stable
Ruby version                  2.1.5-p273 (2014-11-13) [x86_64-linux-gnu]
Rails version                 4.2.5
Environment                   production
Database adapter              Mysql2

I have installed luismaia/redmine_email_fetcher as a plugin, and I have configured it for gmail IMAP. Up to this point I had no error messages and, by trying a test tool on Redmine, I get a success message.

I sum up the plugin configuration on Redmine as it follows:

Configuration type: IMAP
Is configuration active? true
Host : imap.gmail.com
Port: 993
SSL? yes
Email username: mailAddress
Password: mailAccountPwd
Folder Name: Inbox
Method for unknown users: accept

Now, I must run a Cron Job. At this link:

https://github.com/luismaia/redmine_email_fetcher

I have found the following:

*/5 * * * *   www-data /usr/bin/rake -f /opt/redmine/Rakefile --silent redmine:plugins:email_fetcher:fetch_all_emails RAILS_ENV=production 2>&- 1>&

that I personalize as it follows:

*/5 * * * *   www-data /usr/bin/rake -f /opt/redmine/Rakefile --silent redmine:plugins:email_fetcher:fetch_all_emails RAILS_ENV=production host=imap.gmail.com username=mailAddress password= mailAccountPwd port=993  --trace

Coming to the point: the line above doesn't work; and I've no idea why.

I can add that:

  • in /usr/bin I see rake2.1
  • opt directory (/var/opt) is empty.

I do hope I have explained my issue in a decent way.

Thank you in advance, really.

ps: I tried also:

*/5 * * * *   www-data /usr/bin/rake2.1 -f /var/www/redmine/Rakefile redmine:plugins:email_fetcher:fetch_all_emails RAILS_ENV=production 2>&- 1>&- 

but nothing happens.


Solution

  • Test the which command:

    which rake
    

    for me it's in /usr/local/bin and not in /usr/bin

    Next try to chdir in your redmine folder before launch the command in the crontab:

    */5 * * * * cd /var/www/redmine/ && sudo /usr/local/bin/rake redmine:plugins:email_fetcher:fetch_all_emails RAILS_ENV=production 2>&- 1>&- 
    

    Hope this can help you.

    Cheers,

    Luc