0

Run Linux Commands Using the timeout Tool

Question:

how to execute a command with a time limit in linux.

isaac
asked Apr 7, 2021
1 Answer
0

Answer:

  • Its syntax is as follows.
       timeout [OPTION] DURATION COMMAND [ARG]...
    
  • to timeout a ping command after 5 seconds, you can run the following command.
      # timeout 5s ping google.com
    

Sometimes commands may continue to run even after timeout sends the initial signal. In such instances, you can use the --kill-after option.

         -k, --kill-after=DURATION

For example, the command shown is going to be terminated after 8 seconds.

# timeout 8s tail -f /var/log/syslog
View More
linuxhelp
answered Apr 7, 2021
Your Answer
||||
x
 
100:0