title: How to test rake tasks with Whenever Gem?
body: <p>I'm trying to execute a simple rake task using whenever gem but the code isn't being executed.</p>
  
  <p>I already set the environment to development, I updated the cron using the whenever --update-crontab command and the rake task works well if I run the command on console. But, when I run the server the log file is not being generated.</p>
  
  <p>I saw a question here too with the same problem but it was solved setting the environment to development, but didn't work out for me.</p>
  
  <p>My rake task:</p>
  
  <pre><code>namespace :testando do
    task :consulta =&gt; :environment do
      produto = Produto.first
      puts produto.nm_produto
    end  
  end
  </code></pre>
  
  <p>My schedule.rb:</p>
  
  <pre><code>set :output, "#{path}/log/cron_log.log"
  set :environment, 'development'
  
  every 1.minute do
    rake "testando:consulta"
  end
  </code></pre>
  
  <p>I'm using rails 5.0.0.1 and I'm programing in Cloud9, so I think the OS is Ubuntu.</p>
  
  <p>What's missing ?</p>
  
  <p>Update:</p>
  
  <p>I followed the instructions of the main answer in this topic <a href="https://stackoverflow.com/questions/7548730/cron-job-not-working-in-whenever-gem">Cron job not working in Whenever gem</a></p>
  
  <p>And it worked! The task is running even with the server not being started (with "rails s" command).</p>