The following command line call of timeout
(which makes no sense, just for testing reason) does not work as expected. It waits 10 seconds and does not stop the command from working after 3 seconds. Why ?
timeout 3 ls | sleep 10
The 'ls' command shouldn't be taking 3 seconds to run. What I think is happening is you are saying (1) timeout on ls after 3 seconds (again this isn't happening since ls shouldn't take anywhere near 3 seconds to run), then (2) pipe the results into sleep 10 which does not need further arguments than the number you are giving it. Thus ls happens, timeout doesn't matter, and bash sleeps for 10 seconds.
timeout
executesls | sleep 10
. Sincels | sleep 10
will take at least 10 seconds,timeout
should stop it. Buttimeout
does not. – John Threepwood