Saturday, February 08, 2014

Linux: timeout that slow command

Sometimes you need to deal with frozen applications which stay alive longer than expected consuming resources unnecessarily. In linux you just use the timeout command in those situations. For example, given the below command which takes 30 seconds to finish:
$ cat /tmp/slowCommand 
sleep 30
Here is how you make sure it does not take more than 5 seconds:
$ timeout 5 /tmp/slowCommand 

No comments: