在Bash中定时卷曲操作

Rya*_*rio 1 bash time

我想知道使用Curl将一批文件提交到在localhost上运行的HTTP服务器并将其写入文件需要多长时间.我无法正确获取语法.

export TIMEFORMAT="%R"
time -ao times.dat ( curl -v -d @1.batch -X POST $DB )
Run Code Online (Sandbox Code Playgroud)

我怎么能做到这一点?我想这只是使用shell语法的问题.

Pau*_*ce. 5

指定完整路径time(不需要括号):

export TIME="%e"
/usr/bin/time -ao times.dat curl -v -d @1.batch -X POST $DB
Run Code Online (Sandbox Code Playgroud)

请注意,使用不同的环境变量和不同的说明符来获取经过的时间.

time是一个Bash关键字,不支持选项-a-o.

/usr/bin/time 是一个外部二进制文件.

$ type -a time
time is a shell keyword
time is /usr/bin/time
$ help time
time: time [-p] PIPELINE
    Execute PIPELINE and print a summary of the real time, user CPU time,
    and system CPU time spent executing PIPELINE when it terminates.
    The return status is the return status of PIPELINE.  The `-p' option
    prints the timing summary in a slightly different format.  This uses
    the value of the TIMEFORMAT variable as the output format.
$ man time
TIME(1)                                                                TIME(1)

NAME
       time - run programs and summarize system resource usage

SYNOPSIS
       time   [ -apqvV ] [ -f FORMAT ] [ -o FILE ]
              [ --append ] [ --verbose ] [ --quiet ] [ --portability ]
              [ --format=FORMAT ] [ --output=FILE ] [ --version ]
              [ --help ] COMMAND [ ARGS ]

DESCRIPTION
       time  run  the  program  COMMAND with any given arguments ARG....  When
       COMMAND finishes, time displays information  about  resources  used  by
       COMMAND  (on  the standard error output, by default).  If COMMAND exits
       with non-zero status, time displays a warning message and the exit sta?
       tus.
       .
       .
       .