rsync中--out-format的自定义日期/时间格式

时间:2019-01-20 14:48:43

标签: bash rsync datetime-format

根据man页,<embed src="https://cf.milan1.nl/" style="width:294px; height: 109px;"> 用于通过%t输出当前日期和时间。反正有指定日期/时间使用的格式吗?

--out-format

1 个答案:

答案 0 :(得分:1)

似乎没有,没有。查看rsync源代码后,%t格式转义会导致调用以下timestring函数,您可以看到使用以下功能对strftime()进行了硬调用:编码格式字符串"%Y/%m/%d %H:%M:%S"

char *timestring(time_t t)
{
        static char TimeBuf[200];
        struct tm *tm = localtime(&t);
        char *p;

#ifdef HAVE_STRFTIME
        strftime(TimeBuf, sizeof TimeBuf - 1, "%Y/%m/%d %H:%M:%S", tm);
#else
        strlcpy(TimeBuf, asctime(tm), sizeof TimeBuf);
#endif

        if ((p = strchr(TimeBuf, '\n')) != NULL)
                *p = '\0';

        return TimeBuf;
}