If you are using Amazon OpsWork there are two ways to do a Cron Job (here it is for a Ruby on Rails application). One being log in to server write your own and the other being Cron jobs with Chef.
Log in to server is what worked for me and it goes like below. Also make sure you are logged in as root (sudo su) and do 'crontab -e'
*/15 * * * * cd /srv/www/myappname/current; /usr/bin/env /usr/local/bin/ruby bin/rails runner -e production 'Mymodel.my_method'
Corn log is at /var/log/cron or if you like to tail it see what is happening now do 'tail -f /var/log/cron'
As OpsWorks dynamically add severs on runtime, I assume you don't want all your servers run cron jobs. So best to log in to the main 24/7 server and update crontab.
As for chef:
How to for OpsWorks cron at http://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook-extend-cron.html and you could do similar
to
cron "job_name" do
hour "1"
minute "10"
command %Q{
cd /srv/www/myappname/current; /usr/bin/env /usr/local/bin/ruby bin/rails runner -e production "Mymodel.my_method"
}
end
How to with Chef at http://docs.opscode.com/chef/resources.html#cron