Difference between revisions of "Stop a program if it takes more than given time to execute"

From Notes_Wiki
(Created page with "<yambe:breadcrumb>Server_administration_tips_and_tricks|Server administration tips and tricks</yambe:breadcrumb> =Stop a program if it takes more than given time to execute= ...")
 
m
Line 12: Line 12:
</pre>
</pre>
would terminate the sleep program after 5 seconds.
would terminate the sleep program after 5 seconds.
<yambe:breadcrumb>Server_administration_tips_and_tricks|Server administration tips and tricks</yambe:breadcrumb>

Revision as of 07:25, 27 August 2018

<yambe:breadcrumb>Server_administration_tips_and_tricks|Server administration tips and tricks</yambe:breadcrumb>

Stop a program if it takes more than given time to execute

Sometimes there is need of timing out a program and killing it, if it takes more than specified time to execute. To achieve this there is a command 'timeout' with following syntax:

timeout <time><unit> <command>

For example

timeout 5s sleep 10

would terminate the sleep program after 5 seconds.



<yambe:breadcrumb>Server_administration_tips_and_tricks|Server administration tips and tricks</yambe:breadcrumb>