Whenever gem (cron job) not executing rake task, Rails 4
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 8.9k
- Forks
- 715
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to run rake task using whenever gem, did everything what was required but fro some reason cant execute the task successfully.
schedule.rb
set :environment, "development"
set :output, {:error => "log/cron_error_log.log", :standard => "log/cron_log.log"}
every 1.minute do
rake "notify:user"
end
notify_user.rake
namespace :notify do
desc "Rake task to push divisions"
task :user => :environment do
t = Division.trigger_divisions
puts "#{Time.now} - Success!" + t.to_s
end
end
I did whenever --update-crontab and also crontab -l
# Begin Whenever generated tasks for: /home/usman/projects/Saloon/config/schedule.rb
* * * * * /bin/bash -l -c 'cd /home/usman/projects/Saloon && RAILS_ENV=development bundle exec rake notify:user --silent >> log/cron_log.log 2>> log/cron_error_log.log'
# End Whenever generated tasks for: /home/usman/projects/Saloon/config/schedule.rb
# Begin Whenever generated tasks for: store
# End Whenever generated tasks for: store
Log are showing grep CRON /var/log/syslog
Oct 9 15:56:01 usman-Inspiron-3521 CRON[4430]: (usman) CMD (/bin/bash -l -c 'cd /home/usman/projects/Saloon && RAILS_ENV=development bundle exec rake notify:user --silent >> log/cron_log.log 2>> log/cron_error_log.log')
Oct 9 15:57:01 usman-Inspiron-3521 CRON[4453]: (usman) CMD (/bin/bash -l -c 'cd /home/usman/projects/Saloon && RAILS_ENV=development bundle exec rake notify:user --silent >> log/cron_log.log 2>> log/cron_error_log.log')
Oct 9 15:58:01 usman-Inspiron-3521 CRON[4461]: (usman) CMD (/bin/bash -l -c 'cd /home/usman/projects/Saloon && RAILS_ENV=development bundle exec rake notify:user --silent >> log/cron_log.log 2>> log/cron_error_log.log')
Not sure what i am doing wrong here. If i run
cd /home/usman/projects/Saloon && RAILS_ENV=development bundle exec rake notify:user task executes successfully.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with config/schedule.rb and notify_user.rake, then compare the exact generated crontab command with the manual command shown in the report. Check the cron output and error log paths mentioned in the issue; done means identifying why the scheduled invocation differs from the successful manual run and documenting or fixing that behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- cli, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100