In Redmine 0.8.2, I want changeset information fetched automatically, instead of only when someone views the Repository tab of the corresponding project. (I need this so that commit messages containing "refs #42" or "closes #42" have effect as soon as possible.)

The crontab of the user that Redmine runs as has the following entry:

# m h  dom mon dow   command
*/5 * * * * ruby /var/www/redmine/script/runner Repository.fetch_changesets -e production

This used to work prior to a server migration, and it works from the command line (as the Redmine user), but it doesn't work from cron. I can see in the syslog that the command is run:

Feb 15 14:05:01 turing /USR/SBIN/CRON[24119]: (www-data) CMD (ruby /var/www/redmine/script/runner Repository.fetch_changesets -e production)

but the database isn't updated. There are no entries in the Redmine logs.

I got this snippet from the Redmine FAQ. I see that the suggested command has been changed to:

rake -f /path/to/redmine/Rakefile redmine:fetch_changesets

but when I run this from the command line it doesn't pick up the configuration, and thus gets "access denied" when accessing the database.

Which alley should I go down? What obvious thing am I forgetting to check?

  • 2
    Latest version of redmine doesn't have script/runner, all commands are run through rake instead. The actual command you have to use is /path/to/rake -f /path/to/redmine/Rakefile RAILS_ENV=production redmine:fetch_changesets. You can figure out the path to rake with which rake and in Ubuntu it is usually at /usr/local/bin/rake – Spoike Jun 28 '12 at 12:35
  • 1
    Also make sure you edit the appropriate user when editing the crontab, such as www-data you do sudo su www-data; crontab -e; exit; – Spoike Jun 28 '12 at 12:37

It's possible that ruby is in the Redmine user's $PATH but not in cron's. Try specifying the full path in the crontab entry.

*/5 * * * * /path/to/ruby /var/www/redmine/script/runner Repository.fetch_changesets -e production

Also, it would be helpful if you said what error messages or log entries you were getting instead of just saying "doesn't work". The additional information will help with diagnosing the problem.

  • Right, I added the log entry to the question. I tried using the full path, but there was no difference... – legoscia Feb 15 '10 at 14:33
  • I would check to see whether other environment variables are not set when run under cron. – Dennis Williamson Feb 15 '10 at 14:50
  • Turned out to be the PATH after all: not of Ruby, though, but of Mercurial... Also, I found that the system had no mail daemon installed, which was why no failure logs reached me. Adding /usr/local/bin to the PATH setting in the crontab fixed the problem. – legoscia Feb 15 '10 at 15:22
  • This is likely. Cron has very little in the way of defined environment variables. serverfault.com/questions/95729/… – Christopher Karel Feb 15 '10 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.