Sometimes, when you execute a command in Linux, you might want to run it for a set amount of time. There exists a command line utility – timeout – that’s specifically developed for this purpose. In this article, we will discuss the basics of this command using some easy to understand examples.
But before we do that, it’s worth mentioning that all examples in this tutorial have been tested on an Ubuntu 18.04 LTS machine.
Linux timeout command
As the name suggests, the timeout command in Linux allows you to execute a command with a time limit. Following is its syntax:
timeout [OPTION] DURATION COMMAND [ARG]...
And here’s how the tool’s man page explains it:
timeout - run a command with a time limit Start COMMAND, and kill it if still running after DURATION
Following are some Q&A styled examples that should give you a better idea on how this tool works.
Read more at HowToForge