Search code examples
ruby-on-railswhenever

The 'command' method is being ignored by the whenever scheduling gem


I am using the whenever gem to schedule tasks on OSX Mojave. In the scheduling file, I have

#config/schedule.rb
set :output, "log/cron.log"
every 1.day, at: '23:00' do
   rake 'util:something'
   runner 'User.something_else'
   command "echo 'I just want to see something happen'"
end

The rake, and runner methods work fine and I see output in the cron.log. However, there is no output from the command method, it just seems to be ignored. It may be something to do with user permissions, but I am running it from the base directory of my ruby on rails app, so I would have thought I would have the correct permissions.

How do I fix this?


Solution

  • For the 'command' method, it is necessary to specify the full path to the log files, so the output should something like:

    set :output, 'user/sites/my_app/log/cron.log'