在资源'cron [cron_name]'上执行动作`create`时出错

时间:2014-05-07 23:49:17

标签: cron chef aws-opsworks

我无法开始这个cron工作。我正在运行opsworks实例,这是我的秘诀:

cron "delete_error_log" do
  hour "12"
  minute "30"
  command %Q{
  sudo find /srv/www/ -name "error_log" -delete
  }
  action :create
end

我确保cron可以在ssh中运行。

我得到的错误是:

================================================================================
Error executing action `create` on resource 'cron[delete_error_log]'
================================================================================


Chef::Exceptions::Cron
----------------------
Error updating state of delete_error_log, exit: 1


Resource Declaration:
---------------------
# In /opt/aws/opsworks/releases/20140423133810_223/site-cookbooks/cron_job/recipes/delete_error_log.rb

1: cron "delete_error_log" do
2:   hour "12"
3:   minute "30"
4:   command %Q{
5:   sudo find /srv/www/ -name "error_log" -delete
6:   }
7:   action :create
8: end


Compiled Resource:
------------------
# Declared in /opt/aws/opsworks/releases/20140423133810_223/site-cookbooks/cron_job/recipes/delete_error_log.rb:1:in `from_file'

cron("delete_error_log") do
weekday "*"
retry_delay 2
command "\n  sudo find /srv/www/ -name \"error_log\" -delete\n  "
minute "30"
cookbook_name :cron_job
month "*"
retries 0
recipe_name "delete_error_log"
day "*"
action [:create]
user "root"
hour "12"
end
=======================================================

1 个答案:

答案 0 :(得分:1)

问题是多行命令,它似乎直接放入crontab文件中。相反,像这样提供command

cron "delete_error_log" do
  hour "12"
  minute "30"
  command 'sudo find /srv/www/ -name "error_log" -delete'
end