I am running a docker image (with cron already installed) with rails. Everything is running fine, except I'm trying to add a cron job which works as a command, but is giving me an error when adding to crontab.
The following command is:
0,2 * * * * /bin/bash -l -c 'cd /app && bin/rails runner -e production '\''Statistic.create_statistic'\'' >> log/cron_log.log 2>> log/cron_error_log.log'
I made it run every 2 minutes, which I omitted in this snippet for clarity sake.
When I only run:
/bin/bash -l -c 'cd /app && bin/rails runner -e production '\''Statistic.create_statistic'\'' >> log/cron_log.log 2>> log/cron_error_log.log'
It works
The error I get is:
/usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bundler/setup (LoadError)
from /usr/local/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /app/config/boot.rb:3:in `<top (required)>'
from bin/rails:7:in `require_relative'
from bin/rails:7:in `<main>'
I'm using the whenever gem, which seems to be doing its job correctly. What am I doing wrong?