Cron Job for Incoming Mail Not Working on Bitami on EC2
Added by Steve Yoss about 12 years ago
Hello Team --
I'm having an issue executing a cron job check an IMAP mailbox. The rake command will work perfectly fine when executed in the terminal, but does not work when setup as a cron job. I'm at the end of my rope and can't figure it out! I've exhasted my Ruby and Linux knowledge trying to get this to work. Again, either method will work perfect if in typed as a command in the terminal. Cron is definitely running.
I've searched everywhere with no luck. Any help would be greatly, greatly appreciated!!! Thank you!!!
Steve.
Here is what I've tried:
1. Straight rake command in cron
In my crontab I inserted "*/5 * * * * rake -f /opt/bitnami/apps/redmine/Rakefile redmine:email:receive_imap RAILS_ENV="production" host=XX username=XX password=XX port=XX
2. Creation of a shell script --
I tried creating a shell script and tried invoking the shell script from cron. I did this based on the instructions from: http://goo.gl/OGhP8
#!/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 /opt/bitnami/apps/redmine/
rake -f /opt/bitnami/apps/redmine/Rakefile redmine:email:receive_imap RAILS_ENV="production" host=XX username=XX password=XX port=143
exit $ERROR
I chmod'd the .SH file to 770.
I was invoking the script in cron with the command: */1 * * * * /opt/bitnami/apps/redmine/script/redmine-rake-email.sh > /tmp/redmine-email.log 2>&1
When I run grep CRON /var/log/syslog
it produces Jun 28 02:11:01 ip-10-166-221-133 CRON[2609]: (bitnami) CMD (/opt/bitnami/apps/redmine/script/redmine-rake-email.sh > /tmp/redmine-email.log 2>&1)
, but doesn't actually do the rake, download the email,etc.
Any help would be greatly, greatly appreciated!!! Thank you!!!
Replies (2)
RE: Cron Job for Incoming Mail Not Working on Bitami on EC2
-
Added by William Roush about 12 years ago
What does /tmp/redmine-email.log have in it?
Does the bitnami user have execute permissions on redmine-rake-email.sh?
Have you "su bitnami" and tried executing the cron job's command? "/opt/bitnami/apps/redmine/script/redmine-rake-email.sh > /tmp/redmine-email.log 2>&1"
RE: Cron Job for Incoming Mail Not Working on Bitami on EC2
-
Added by Steve Yoss about 12 years ago
It's fixed. I wasn't envoking the correct enviroment. Here is what I put for cron:
*/5 * * * * cd /opt/bitnami/apps/redmine/htdocs; /opt/bitnami/ruby/bin/rake -f /opt/bitnami/apps/redmine/Rakefile redmine:email:receive_imap RAILS_ENV="production" host=XX username=XX password=XX port=XX
Thank you!!!!