Reputation: 97
in my config/schedule.rb
:
set :environment, "development"
set :output, "log/cron.log"
every 2.minutes do
rake "reset_expired_pin:generate"
end
then i run whenever --update-crontab --set environment='development'
then crontab -l
i see the cron in that list
and after I refresh my DB every 2 mins, it doesn't update anything ( my rake command not run ),
I have a search on this issue on this StackOverflow and do what the answers said, but doesn't work so i finally ask here to get help,
is wheneever gem
not support on OSX ? and can't be running in development mode ??
i also can't found the log file of that cron , i thought it gonna saved in my rails app root, but it doesn't, i follow this intructions to get log, and i follow this instructions for run whenever
but nothing lucking to find this log in my Mac
crontab -l
:
# Begin Whenever generated tasks for: /Users/me/Documents/myapp/config/schedule.rb at: 2020-05-16 07:12:15 +0800
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /bin/bash -l -c
'export PATH="$HOME/.rbenv/bin:$PATH"; eval "$(rbenv init -)"; cd /Users/me/Documents/myapp && RAILS_ENV=development bundle exec rake reset_expired_pin:generate --silent >> log/cron.log 2>&1'
# End Whenever generated tasks for: /Users/me/Documents/myapp/config/schedule.rb at: 2020-05-16 07:12:15 +0800
Upvotes: 3
Views: 992
Reputation: 97
i found it just now, been find out this problem since yesterday and found out just now, to resolve it, we should set up the env of RBENV if you are using RBENV and set the version of ruby and it gonna find the ruby-version in your root file app rail i set it up it
set :rbenv_root, '~/.rbenv'
set :rbenv_version, '2.7.1'
env 'RBENV_ROOT', rbenv_root
env 'RBENV_VERSION', rbenv_version
job_type :rake, 'export PATH="$HOME/.rbenv/bin:$PATH"; eval "$(rbenv init -)"; cd :path && :environment_variable=:environment bundle exec rake :task --silent :output'
set :environment, "development"
env of RBENV must on the top
and on that job_type:
we set it up for get the PATH of rbenv because it gonna run by bash
one thing is more importan the ~/Libary on Mac must be executable, so we could it set up for cron follow this : https://blog.bejarano.io/fixing-cron-jobs-in-mojave/
Upvotes: 4