0

The rake task seems never launched by Cron in a Ruby on Rails 5 application (Openproject 7)

openproject$ crontab -l
* * * * * cd /home/openproject/openproject-ce && RAILS_ENV=production bundle exec rake jobs:workoff >> log/cron.log

The log file is never created and the task is not performed (no debug info)....

What should I do ?

EDIT :

By running the rails console in the production environnement, I always have pending jobs :

Delayed::Job.count ==> 2

Running the same instruction with the same user (openproject) directly in the ssh console works successfully :

RAILS_ENV=production bundle exec rake jobs:workoff
    ==> returns successfully and Delayed::Job.count ==> 0

The cron daemon seems to be running :

sudo service cron status
    cron.service - Regular background program processing daemon
    Loaded: loaded (/lib/systemd/system/cron.service; enabled)
    Active: active (running) since Sat 2017-07-15 16:03:13 CEST; 2 months 0 days ago

What do I miss ?

Stéphane V
  • 1,094
  • 2
  • 11
  • 25
  • Can't point you to anything specific but it still sounds like an access problem. When taking a look at the first console statement I noticed that it reads `openpjorect` as opposed to `openproject` so there might be a typo somewhere. – ulferts Sep 17 '17 at 19:16
  • I updated the typo. I is indeed not a typo issue... Is there a way to check/simulate the execution of this cron task ? – Stéphane V Sep 18 '17 at 12:37
  • Did you check the access to `log/cron.log`? – ulferts Sep 18 '17 at 19:22
  • Yes, no file is created. I think the cron is never launched or exit before writing the file... – Stéphane V Sep 19 '17 at 06:50

1 Answers1

0

I found the solution thanks to a very good advice : the environnement variable are different for the cron and for a normal user (shell is not identical... obscure reason).

By adding directly in the cron th einstruction "source /home/username/.profile; " the problem was gone.

My .profile contains the adding of "rbenv" and "node" in the path, "rbenv init -" and same for node...

Stéphane V
  • 1,094
  • 2
  • 11
  • 25