If I want to time the running of rsync
by time rsync -a /media/t/1/ ./
, after it finishes, does $?
report the exit value for time
not for rsync
?
How can I both time rsync
and get its exit value?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityBash's built-in time returns the exit status of the command. You can test that fairly easily with time false
; afterwards, echo $?
prints 1 as expected. You can also test something with a different exit code to confirm other codes are preserved:
$ time bash -c 'exit 42'; echo "Exit code: $?"
real 0m0.002s
user 0m0.000s
sys 0m0.000s
Exit code: 42