I've this script in my recipe
cron "logs_processPageView" do
minute "*"
hour "*"
day "*"
month "*"
weekday "*"
command %Q{
echo "hi" >> /home/ubuntu/test.txt
}
action :create
end
When I run the recipe with opswork, here is the corresponding log
[Fri, 12 Jul 2013 02:42:48 +0000] DEBUG: Processing cron[logs_processPageView] on test1.localdomain
[Fri, 12 Jul 2013 02:42:48 +0000] DEBUG: Cron 'logs_processPageView' not found
[Fri, 12 Jul 2013 02:42:48 +0000] INFO: Added cron 'logs_processPageView'
{code}
I assumed the cron have been added to the cron job.
But when I ssh'd to the instance, there is no test.txt, even if I wait an hour. Also there is no new cronjob when I run {code}sudo crontab -l{code} or {code}crontab -l{code}.
Why the resource not adding the cronjob?
I tried to use cron cookbook. There is new file in /etc/cron.d/cronfile, but the cron still not working.
What did I've done wrong? And how to fix it?
This is a bug because opswork was using Chef 9 (very outdated Chef).
Currently they have already upgraded to Chef 11.4, so you can try again, because my script in the question now is working.