Code Monkey home page Code Monkey logo

bash-timeout3's Introduction

timeout3 - execute a command with a timeout

Execute a command with a time-out. Upon time-out expiration SIGTERM (15) is sent to the process. If SIGTERM signal is blocked, then a subsequent SIGKILL (9) terminates it.

Install

Something like

git clone https://github.com/jbenet/bash-timeout3
mv bash-timeout3/timeout3-v2 /usr/bin/timeout3

Usage

Examples

# timeout $(sleep 10) at 5 seconds.
> ./timeout3-v1 -t 5 sleep 10
Terminated: 15

v1

> ./timeout3-v1
Synopsis
    timeout3-v1 [-t timeout] [-i interval] [-d delay] command
    Execute a command with a time-out.
    Upon time-out expiration SIGTERM (15) is sent to the process. If SIGTERM
    signal is blocked, then the subsequent SIGKILL (9) terminates it.
    -t timeout
        Number of seconds to wait for command completion.
        Default value: 9 seconds.
    -i interval
        Interval between checks if the process is still alive.
        Positive integer, default value: 1 seconds.
    -d delay
        Delay between posting the SIGTERM signal and destroying the
        process by SIGKILL. Default value: 1 seconds.
As of today, Bash does not support floating point arithmetic (sleep does),
therefore all delay/time values must be integers.

v2

> ./timeout-v2
Synopsis:  timeout3-v2 [-t timeout] [-i interval] [-d delay] command

Executes the command with a time-out.  Upon time-out expiration SIGTERM (15) is
sent to the process.  If SIGTERM signal is blocked, then the subsequent SIGKILL
(9) terminates it.

-t timeout
    Number of seconds to wait for command completion.
    Default value: 5 seconds.  In some practical situations
    this value must be increased (for instance -t 180) to allow
    the command to complete.

-i interval
    Interval between checks if the process is still alive.
    Positive integer, default value: 1 seconds.
    Default value is OK for most situations.

-d delay
    Delay between posting the SIGTERM signal and destroying the process by
    SIGKILL.  Default value: 1 seconds.
    Default value is OK for most situations.

As of today, Bash does not support floating point arithmetic (sleep does),
therefore all time values must be integers.

History

This little script has a fun history:

See version histories at:

License

MIT

bash-timeout3's People

Contributors

jbenet avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.