How i can add cron entry without time using chef

177 views Asked by At

Via cookbook recipe i want to add crontab entry which will help me to start application whenever my VM will restart so with entry i don't want to specify anytime i tried with this code:-

cron 'Reboot_entry' do
  user node['aem_vm_cookbook']['owner']['user']
  command '@reboot /bin/rm -f /ebiz/aem/crx-quickstart/conf/cq.pid ; source /etc/profile.d/aemprofile.sh > /dev/null ; /ebiz/aem/crx-quickstart/bin/start > /ebiz/aem/crx-quickstart/logs/reboot.log 2>&1'
end

For this i did not specify anytime but it is creating entry with * mark which looks like this:-

* * * * * @reboot /bin/rm -f /ebiz/aem/crx-quickstart/conf/cq.pid ; source /etc/profile.d/aemprofile.sh > /dev/null ; /ebiz/aem/crx-quickstart/bin/start > /ebiz/aem/crx-quickstart/logs/reboot.log 2>&1

This entry is working fine when VM restart but the problem it is executing every minute and if i am stopping application for some work it will start after one minute.I just want to work this reboot entry only for VM restart. If i am removing all stars this is working fine.

So i don't need any * while adding this cron entry.

1

There are 1 answers

0
seshadri_c On

The time property of the cron resource takes special times such as @reboot (:reboot). So your resource should be like:

cron 'Reboot_entry' do
  command '/bin/rm -f /ebiz/aem/crx-quickstart/conf/cq.pid ; source /etc/profile.d/aemprofile.sh > /dev/null ; /ebiz/aem/crx-quickstart/bin/start > /ebiz/aem/crx-quickstart/logs/reboot.log 2>&1'
  user node['aem_vm_cookbook']['owner']['user']
  time :reboot
end