On Linux, you can run a command for a specific amount of time using the timeout utility:
timeout <time> <command>
For example, to recursively list all files in the current working directory for no longer than 2 seconds, open a terminal and run:
timeout 2s ls -R
The command which is passed as an argument to timeout will be automatically killed if it is still running after the specified amount of time. If this is the case, the exit status code of timeout will be 124 (not zero!).
For more on this topic, see the man page of timeout:
man timeout
Comments
No comments posted yet.