You are correct that it does not behave as documented:
$ rclone copy . crypt:test --max-duration=5s -P
2023-07-14 11:19:22 NOTICE:: Failed to cancel multipart upload: ....: context deadline exceeded)
2023-07-14 11:19:22 ERROR : test: Failed to copy:....: context deadline exceeded
2023-07-14 11:19:22 ERROR : Encrypted drive 'crypt:test': max transfer duration reached as set by --max-duration
2023-07-14 11:19:22 ERROR : Fatal error received - not attempting retries
Transferred: 4.501 MiB / 4.501 MiB, 100%, 1.125 MiB/s, ETA 0s
Errors: 2 (fatal error encountered)
Elapsed time: 5.9s
2023/07/14 11:19:22 Failed to copy with 2 errors: last error was: max transfer duration reached as set by --max-duration
# current transfer has been cancelled
$ echo $?
7
$ rclone copy . crypt:test --max-duration=5s -P --cutoff-mode=soft
2023-07-14 11:11:19 ERROR : Encrypted drive 'crypt:test': max transfer duration reached as set by --max-duration
2023-07-14 11:11:19 ERROR : Cancelling sync due to fatal error: max transfer duration reached as set by --max-duration
2023-07-14 11:11:19 ERROR : Fatal error received - not attempting retries
Transferred: 30.007 MiB / 30.007 MiB, 100%, 645.276 KiB/s, ETA 0s
Errors: 1 (fatal error encountered)
Transferred: 1 / 1, 100%
Elapsed time: 42.4s
2023/07/14 11:11:19 Failed to copy: max transfer duration reached as set by --max-duration
# current transfer finished
$ echo $?
7
Docs:
--max-duration=TIME
Rclone will stop scheduling new transfers when it has run for the duration specified.
Defaults to off.
When the limit is reached any existing transfers will complete.
Rclone won't exit with an error if the transfer limit is reached.
So there are few issues here.
- It is not documented that --cutoff-mode applies to
--max-duration
as well:
--cutoff-mode=hard|soft|cautious
This modifies the behavior of
--max-transfer
Defaults to--cutoff-mode=hard
.
-
Contrary to
--max-duration
description it does not stop scheduling but terminates immediately and existing transfers are not completed - but as--cutoff-mode
works it is only documentation problem -
Even when
--cutoff-mode=soft
is used rclone exits with error code 7
I will update documentation but I am not sure if error code 7 is by design or it is bug? @ncw ? IMHO we should add new error code 10:
List of exit codes
0
- success1
- Syntax or usage error2
- Error not otherwise categorised3
- Directory not found4
- File not found5
- Temporary error (one that more retries might fix) (Retry errors)6
- Less serious errors (like 461 errors from dropbox) (NoRetry errors)7
- Fatal error (one that more retries won't fix, like account suspended) (Fatal errors)8
- Transfer exceeded - limit set by --max-transfer reached9
- Operation successful, but no files transferred10
- Duration exceeded - limit set by --max-duration reached