【发布时间】:2020-08-24 11:05:32
【问题描述】:
您好,我正在尝试使用 bash 创建日志,但我得到的时间是错误的。我在后台运行它。
# log code here before executing curl script log "Yay I was started"
curl https://example.com/process | sed "s/^/$(date -u) /" >> /path/to/logs.log &
处理 curl 后设置的时间是执行的时间,而不是我得到响应后的时间。我需要得到响应后的时间。
这是示例输出(错误响应)
Fri Aug 21 01:43:12 UTC 2020 Yay I was started
Fri Aug 21 01:43:12 UTC 2020 Yay I was the response returned by the url
https://example.com/process 此处的 url 休眠了 2 秒,但正如您所见,执行它的时间和之后我们得到响应的时间是相同的。
正确回答
Fri Aug 21 01:43:12 UTC 2020 Yay I was started
Fri Aug 21 01:43:14 UTC 2020 Yay I was the response returned by the url
我该如何解决这个问题?
【问题讨论】: