【问题标题】:Copy file from .ebextentions folder从 .ebextentions 文件夹复制文件
【发布时间】:2020-06-10 13:26:41
【问题描述】:

我想从 .ebextentions/td-agent.conf 归档到 /etc/td-agent/td-agent.conf。但它无法正常工作并低于错误。

如果您看到附加图片,则 .ebextentions 中有 3 个文件。我已将复制命​​令放入 01-main.config。

--- 

container_commands: 
  01_cron_job: 
    command: "touch /tmp/is_leader"
    leader_only: true
  01_tdconfcopy_job: 
    command: "yes | cp .ebextensions/td-agent.conf /etc/td-agent/td-agent.conf"

错误如下

Command failed on instance. Return code: 1 Output: cp: cannot create regular file '/etc/td-agent/td-agent.conf': No such file or directory

【问题讨论】:

    标签: amazon-web-services amazon-elastic-beanstalk ebextensions


    【解决方案1】:

    问题是您将文件复制到不存在的目录中。您应该先创建输出目录,然后复制配置文件。

    原来是这样:

    --- 
    
    container_commands: 
    01_cron_job: 
        command: "touch /tmp/is_leader"
        leader_only: true
    01_create_dir: 
        command: "sudo mkdir -p /etc/td-agent/"
    02_tdconfcopy_job: 
        command: "yes | cp .ebextensions/td-agent.conf /etc/td-agent/td-agent.conf"
    

    或者,您可以使用files 命令直接在服务器上创建文件。

    files:
        "/etc/td-agent/td-agent.conf":
            mode: "000644"
            owner: root
            group: root
            content: |
                content of your config file that you want to copy
    

    【讨论】:

    • 是的,这是一种方式。但是我们必须有方法可以复制文件,文件内容可能会随着时间的推移而变大。
    • @JaishreeMishra,我已经更新了答案。复制失败,因为 /etc/td-agent/ 不存在,应先创建。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-11
    • 1970-01-01
    • 2017-03-31
    • 1970-01-01
    • 2021-09-24
    • 1970-01-01
    相关资源
    最近更新 更多