Stop an application after a specific amount of time

Sometimes you want to stop a process after it is running for some time. Probably because you want to avoid a script or process being stuck, or simply limiting the resources it can use.

Examples

timeout --kill-after=5s 10s sleep 8

Run a command for a while and set a timeout to it, after which is will be terminated automatically

This command gives the sleep command 10 seconds (10s) the time to run the job of 8 seconds. In case sleep does not respond to the TERM signal to terminate, then a KILL signal will be sent after 5 seconds.



Do you like this page? Share it with others or help us make it better

Yes!

Share with friends:
Share on Twitter