{"id":18466521,"url":"https://github.com/mountainfield/bash-timeout","last_synced_at":"2025-12-14T12:53:32.398Z","repository":{"id":57414065,"uuid":"137163479","full_name":"MountainField/bash-timeout","owner":"MountainField","description":"timeout function written by Bash","archived":false,"fork":false,"pushed_at":"2018-06-23T07:25:23.000Z","size":16,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-28T15:44:17.951Z","etag":null,"topics":["bash","shell","shell-script","timeout"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MountainField.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-13T04:42:42.000Z","updated_at":"2022-02-23T03:52:19.000Z","dependencies_parsed_at":"2022-09-14T07:21:18.824Z","dependency_job_id":null,"html_url":"https://github.com/MountainField/bash-timeout","commit_stats":null,"previous_names":["nogayama/bash-timeout"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/MountainField/bash-timeout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MountainField%2Fbash-timeout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MountainField%2Fbash-timeout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MountainField%2Fbash-timeout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MountainField%2Fbash-timeout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MountainField","download_url":"https://codeload.github.com/MountainField/bash-timeout/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MountainField%2Fbash-timeout/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274729074,"owners_count":25338600,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","shell","shell-script","timeout"],"created_at":"2024-11-06T09:16:38.043Z","updated_at":"2025-12-14T12:53:32.316Z","avatar_url":"https://github.com/MountainField.png","language":"Shell","readme":"Bash Timeout\n============\n\n[bash-timeout](https://github.com/nogayama/bash-timeout) is a command and also a bash function in order to terminate the target command if the target command does not finish within the duration specified beforehand. \nThe input via either redirection ( \u003c FILE ) or pipe ( | ) are transferred to the target command transparently.\nThe exit status of the target command is retained if the target command finishes within the duration.\n\nThe [timeout](https://www.gnu.org/software/coreutils/manual/html_node/timeout-invocation.html) in GNU coreutils is a similar command which has the timeout capability.\nIn shell script, bash-timeout make the script simpler than GNU timeout.\nSee [comparison.md](docs/comparison.md) for more details.\n\n\u003c!--\n\nGetting started\n----------------\n\n### Prerequisites\n\n- `bash` (version 3 or later), `sleep`, `pkill`,`ps`\n--\u003e\n\nInstalling\n----------\n\n- via pip\n    \n        $ pip install bash-timeout\n\n\u003c!--- Install via yum\n    \n    1. Download repository definition\n        \n        ```bash\n        $ sudo curl -kL -o /etc/repos.d/bash-timeout.repo  https://github.com/nogayama/bash-timeout/master/bash-timeout.repo\n        ```\n    \n    2. Do yum command\n    \n        ```bash\n        $ sudo yum install bash-timeout\n        ```\n\n- Install via rpm\n\n    1. Do rpm command\n\n        ```bash\n        $ sudo rpm -ivh https://github.com/nogayama/bash-timeout/master/bash-timeout.rpm\n        ```\n\n- Install executable directory\n\n    1. Copy executable to directory included in `$PATH` environmental variable\n\n        ```bash\n        $ curl -kL -o /usr/local/bin/bash-timeout  https://github.com/nogayama/bash-timeout/master/bin/bash-timeout\n        $ chmod +x /usr/local/bin/bash-timeout\n        ```--\u003e\n\nUsage\n-----\n\n- Use as a linux/unix command\n\n    ```bash\n    $ bash-timeout 10s sleep 20s\n    ```\n\n- Use as a bash function\n\n    ```bash\n    source bash-timeout\n    timeout 10s sleep 20s\n    ```\n\n- An example in bash script\n\n    ```bash\n    source bash-timeout\n    \n    function very_expensive_task() {\n        ...\n    }\n    \n    if timeout 10s  very_expensive_task  ; then\n        echo \"successfully done\"\n    else\n        echo \"the task failed or timed out\"\n    fi\n    ```\n\n\nCharacteristics\n---------------\n\n1. Status code\n    \n    1. Return error code if time out\n\n        ```bash\n        $ bash-timeout 10s sleep 20s\n        $ echo $? #=\u003e 1 or more \n        ```\n\n    2. Retain the target command status code if the target command finishes within the duration\n\n        1. Normal exit\n            \n            ```bash\n            $ bash-timeout 10s ls /bin\n            $ echo $? #=\u003e 0\n            ```\n\n        2. Exit with error\n            \n            ```bash\n            $ ls /FOOBAR\n            $ echo $? #=\u003e 2\n            ```\n            \n            ```bash\n            $ bash-timeout 10s ls /FOOBAR\n            $ echo $? #=\u003e 2\n            ```\n\n2. Input and Output\n\n    - Retain output\n\n        ```bash\n        $ echo abc #=\u003e abc \n        ```\n\n        ```bash\n        $ bash-timeout 10s echo abc #=\u003e abc \n        ```\n\n    - Retain input via pipe\n\n        ```bash\n        $ echo abc | cat #=\u003e abc \n        ```\n    \n        ```bash\n        $ echo abc | bash-timeout 10s cat #=\u003e abc \n        ```\n\n    - Retain input via redirection\n\n        ```bash\n        $ echo abc \u003e abc.txt\n        $ cat \u003c abc.txt  #=\u003e abc \n        $ \u003c abc.txt cat  #=\u003e abc \n        ```\n    \n        ```bash\n        $ bash-timeout 10s cat \u003c abc.txt  #=\u003e abc \n        $ bash-timeout \u003c abc.txt 10s cat  #=\u003e abc \n        $ \u003c abc.txt bash-timeout 10s cat  #=\u003e abc \n        ```\n\nAuthor\n------\n\n* **Takahide Nogayama** - [Nogayama](https://github.com/nogayama)\n\nLicense\n-------\n\nThis project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.txt) file for details\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](docs/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\nAcknowledgments\n---------------\n\nWe express our sincere thanks to Scott Trent for reviewing documents.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmountainfield%2Fbash-timeout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmountainfield%2Fbash-timeout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmountainfield%2Fbash-timeout/lists"}