OK, that’s enough computer time. You can give processes time limits, setting a maximum time they can run for with the
timeoutcommand. Here’s a tutorial to putting limits on running programs with this command.
What Does timeout Do For You?
timeout command allows you to set a limit on the length of time a program will run for. But why would you want to do that?
One case is when you know exactly how long you want a process to run for. A common use-case is to have
timeout control a logging or data-capture program so that the log files don’t relentlessly devour your hard drive space.
Another case is when you don’t know how long you want a process to run for, but you do know you don’t want it to run indefinitely. You might have a habit of setting processes running, minimizing the terminal window, and forgetting about them.
Some programs–even simple utilities—can generate network traffic at levels that can impede the performance of your network. Or they can tie up the resources on a target device, slowing down its performance. (
ping, I’m looking at you.) Leaving these types of programs running for extended periods while you’re away from your computer is bad practice.
Getting Started With timeout
Here’s a simple example. For example, with its default command-line options, the
ping command will run until you stop it by hitting Ctrl+C. If you don’t interrupt it, it’ll just keep going.
timeout, we can make sure
ping doesn’t run on and on, chewing up network bandwidth and pestering whatever device is being pinged.
Proactive Computing found this story and shared it with you.
The Article Was Written/Published By: Dave McKay