Home Ask Login Register

Developers Planet

Your answer is one click away!

Babar February 2016

Whenever Gem and cron Job

I followed the instruction on Whenever gems website, and tried following it in both development and on production mode on server.

set :output, "/file/to/path/cron.log"
every 1.day, at: '11:59 pm' do
   command "sudo touch /file/to/path"
   runner "Location.transfer_data",:environment => 'production' 
end

It doesn't create the file(which is a test for now since I have no data on production).

I have spent hours trying to debug it and crontab -l gives me this output

59 23 * * * /bin/bash -l -c 'sudo touch /file/to/path >> /file/to/path/cron.log 2>&1'

59 23 * * * /bin/bash -l -c 'cd /var/www/name && script/rails runner -e production '\''Location.transfer_data'\'' >> /file/to/path/cron.log 2>&1'

Regards,

Babar Rehman

Answers


Babar February 2016

I solved the issue, don't know which one solved it in particular but these were the step that I took

  1. Added job name to whenever --update-cron command

whenever --update-cron jobName

  1. Restarted the cron service

sudo service cron restart

  1. Gave full access rights to the log file

sudo chmod 777 /path/to/file.log

Hope it will come in handy for others

Post Status

Asked in February 2016
Viewed 1,954 times
Voted 10
Answered 1 times

Search




Leave an answer


Quote of the day: live life