gpt4 book ai didi

rundeck - 如何从 Rundeck 作业检索日期

转载 作者:行者123 更新时间:2023-12-02 12:16:16 33 4
gpt4 key购买 nike

我正在尝试在 rundeck 2.6 工作中实现类似的目标:

touch/foo/bar/${DATE:MM/dd/yyyy}-baz

但它无法正常工作并且日期根本没有被解释。有没有正确的方法来做到这一点?

最佳答案

您可以使用这个 bash 脚本:

#!/bin/bash
touch /foo/bar/`date "+%m/%d/%Y"`-baz

反引号的作用为 command substitution并替换 date 的输出touch 中的命令命令。

根据date man page :

An operand with a leading plus (`+') sign signals a user-defined format string which specifies the format in which to display the date and time. The format string may contain any of the conversion specifications described in the strftime(3) manual page, as well as any arbitrary text.

日期格式字符串使用以下conversion specifier character :

  • %m The month as a decimal number (range 01 to 12). (Calculated from tm_mon.)
  • %d The day of the month as a decimal number (range 01 to 31). (Calculated from tm_mday.)
  • %Y The year as a decimal number including the century. (Calculated from tm_year)

关于rundeck - 如何从 Rundeck 作业检索日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41283718/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com