zoukankan      html  css  js  c++  java
  • linux bash timeout

     

    http://www.digitalinternals.com/unix/unix-linux-run-command-with-timeout/500/

     

    There are two ways to send a SIGKILL signal to the process from the timeout utility. The first way is by specifying the default signal to be sent using the following syntax.

    $ timeout -s KILL 1m /path/to/slow-command arg1 arg2

    The second way is to first send the SIGTERM after the initial timeout. Then, wait for another timeout and send a SIGKILL to the process if it’s still running. This can be done using the following syntax.

    $ timeout -k 30 1m /path/to/slow-command arg1 arg2

    The process is sent a SIGTERM signal after 60 seconds. If it is still running, then a SIGKILL signal is sent after another 30 seconds.

    In the event that the timeout utility is not available, the below 1-liner can be used as an alternative.

    $ /path/to/slow-command arg1 arg2 & sleep 60; kill $!

    The slow-command is started as a background process. The sleep command will then pause till the timeout duration. In our case, it will sleep for 60 seconds. Once 60 seconds has elapsed, the kill command will send a SIGTERM signal to the slow-command process. The ‘$!‘ shell variable will give the PID of the last background job.

  • 相关阅读:
    数据结构实验2-迷宫
    离散实验4
    关系代数中的除法运算
    数据库中什么叫象集
    (转)汇编-补码
    2014022201
    20140222
    2014022101
    代码20140221
    代码20140215
  • 原文地址:https://www.cnblogs.com/itech/p/7306967.html
Copyright © 2011-2022 走看看