I have a script that creates and copies a file to multiple machine on a network.
Sometimes a machine or two may be down, which in turn causes the cp to take a really long time to timeout.
My questions are:
- what is the default timeout of this?
- Can one actually override this in order to lower it?
cp, by itself, does not impose a timeout. If one of the filesystems blocks or is slow, the command could keep running for an arbitrarily long time.
You could try forcing the command to stop after a while using
timeout: for example
timeout 30 cp <source> <destination> would start
cp and then kill it if it has not completed after 30 seconds. Depending on why, in your use case, the copy takes an abnormally long time, this may or may not do what you want.
rsync has a timeout options
--timeout=SECONDS set I/O timeout in seconds
you can use it as an enhanced cp.