How to Run a Command with Time Limit in Bash Linux

Posted on April 6, 2019 at 2:48 pm

You can use “timeout” command to run a program and auto-kill it after N seconds:

timeout --signal=KILL 3 whois google.cd

The above command will auto-kill whois if it runs for more than 3 seconds.

Here is an example output in a Debian server:

root@server:~# timeout --signal=KILL 3 whois google.cd
Killed

More information here:

https://linux.die.net/man/1/timeout

Receive updates via email

Other Posts

Updated Posts