簡體   English   中英

我如何使用廚師無需時間添加 cron 條目

[英]How i can add cron entry without time using chef

通過食譜食譜,我想添加 crontab 條目,這將幫助我在我的虛擬機重新啟動時啟動應用程序,因此我不想在任何時候嘗試使用此代碼時指定條目:-

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

為此,我沒有指定任何時間,但它正在創建帶有 * 標記的條目,如下所示:-

* * * * * @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

當 VM 重新啟動時,此條目工作正常,但問題是每分鍾執行一次,如果我停止應用程序進行某些工作,它將在一分鍾后啟動。我只想為 VM 重新啟動工作此重新啟動條目。 如果我刪除所有星星,這工作正常。

所以我在添加這個 cron 條目時不需要任何 * 。

cron 資源time屬性需要特殊時間,例如@reboot ( :reboot )。 所以你的資源應該是這樣的:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM