在资源上执行操作“create”时出错cron [cron_name] [英] Error executing action `create` on resource 'cron[cron_name]'

查看:262
本文介绍了在资源上执行操作“create”时出错cron [cron_name]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法得到这个cron工作开始。我正在运行opsworks实例,这是我的食谱:

  crondelete_error_logdo 
小时12
分钟30
命令%Q {
sudo find / srv / www / -nameerror_log-delete
}创建
end


$ b $ p我已经确保cron可以在ssh中运行。 / p>

我得到的错误是:

  ==== ==================================================== ======================== 
在资源上执行操作create时出错cron [delete_error_log]'
== ==================================================== ============================


Chef :: Exceptions :: Cron
----------------------
更新delete_error_log的状态时出错:1


资源声明:
---------------------
#In / opt / aws / opsworks / releases / 20140423133810_223 / site-cookbooks / cron_job / recipes /delete_error_log.rb

1:crondelete_error_logdo
2:小时12
3:分钟30
4:命令%Q {
5:sudo find / srv / www / -nameerror_log-delete
6:}
7:action:create
8:end


编译资源:
------------------
#声明在/ 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
命令 \\\
sudo find / srv / www / -name \error_log\-delete\\\

minute30
cookbook_name:cron_job
month*
retries 0
recipe_namedelete_error_log
day*
action [:create]
userroot
hour12
end
============================================== =========


解决方案

是多行命令,这似乎是直接放到crontab文件中。而是像这样提供命令

  crondelete_error_logdo 
小时12
分钟30
命令sudo find / srv / www / -nameerror_log-delete'
end


I cannot get this cron job to get started. I am running opsworks instances and this is my recipe:

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

I have made sure that the cron would work by running inside ssh.

The error I am getting is this:

================================================================================
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
=======================================================

解决方案

The problem is the multi-line command, which seems to be directly put into the crontab files. Instead, supply the command like this:

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

这篇关于在资源上执行操作“create”时出错cron [cron_name]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆