title: Whenever cronjobs does not run on staging
body: <p>I am trying to make a simple cron job running this task:
  Here is my schedule.rb:</p>
  
  <pre><code>set :environment, "staging"
  set :path, "/var/www/my_app/current"
  every 2.minutes do
    # specify the task name as a string
    rake 'cron_test'
  end
  </code></pre>
  
  <p>Here is the task:</p>
  
  <pre><code>task :cron_test =&gt; :environment do
    out_file=File.new("cron_test.txt", "w")
    out_file.puts(Time.now.to_s)
    out_file.close
  end
  </code></pre>
  
  <p>I tried to do what is advised on this page but nothing works: 
  <a href="https://stackoverflow.com/questions/7548730/cron-job-not-working-in-whenever-gem">Cron job not working in Whenever gem</a></p>
  
  <p>When I run crontab -l :</p>
  
  <pre><code># Begin Whenever generated tasks for: /var/www/my_app/current/config/schedule.rb
  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 'cd /var/www/my_app/current &amp;&amp; RAILS_ENV=staging bundle exec rake cron_test'
  
  # End Whenever generated tasks for: /var/www/my_app/current/config/schedule.rb
  </code></pre>
  
  <p>When I run grep CRON /var/log/syslog:</p>
  
  <pre><code>Jun 29 17:22:01 my_server CRON[21164]: (root) CMD (/bin/bash -l -c 'cd /var/www/my_app/current &amp;&amp; RAILS_ENV=staging bundle exec rake cron_test')
  </code></pre>
  
  <p>Any ideas? </p>
  
  <p>Thanks</p>