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.
linux bash timeout的更多相关文章
- 转: windows 10使用原生linux bash命令行
转: https://www.zybuluo.com/pandait/note/337430 windows 10使用原生linux bash命令行 linux bash windows-10 第一时 ...
- Linux Bash代码 利用for循环实现命令的多次执行
Linux Bash代码 [yuanhao15@lu01 libsvm-rank-2.81]$ for ((i=0; i<=19; i++)) do ./svm-train -s 5 -c 10 ...
- linux BASH shell设置字体与背景颜色
linux BASH shell下设置字体及背景颜色的方法. BASH shell下设置字体及背景颜色 echo -e "\e[31mtest\e[41m" \e[30m 将字 ...
- Linux:-bash: ***: command not found
Linux:-bash: ***: command not found,系统很多命令都用不了,均提示没有此命令. 突然之间linux很多命令都用不了,均提示没有此命令. 这应该是系统环境变量出现了问题 ...
- Linux Bash命令关于程序调试详解
转载:http://os.51cto.com/art/201006/207230.htm 参考:<Linux shell 脚本攻略>Page22-23 Linux bash程序在程序员的使 ...
- 禁用Linux bash rm --force
防止无意的Linux bash rm --force 二.禁用rm -rf 因为rm -rf 删除文件的时候,经常会不小心将系统文件或者多个有用的目录删除掉.有两种方法:1,每次删除都用-i(inte ...
- linux bash关闭标准输出1(exec 1<&-)后重新打开
linux bash shell的再次学习. 文件描述符: stdin,stdout 和 stderr 的文件描述符分别是 0,1 和 2(一个文件描述符说白了就是文件系统为了跟踪这个打开的文件而分配 ...
- win10开启 linux Bash命令(win10内置了linux系统支持)
win10开启 Ubuntu linux Bash命令(win10内置了linux系统支持) 第一步: 先在设置→更新和安全→针对开发人员中选择"开发人员模式",点击后会下载&qu ...
- 【Linux】linux bash shell之变量替换::=句法、=句法、:-句法、-句法、=?句法、?句法、:+句法、+句法
linux bash shell之变量替换::=句法.=句法.:-句法.-句法.=?句法.?句法.:+句法.+句法 linux bash shell之变量替换::=句法.=句法.:-句法.-句法. ...
随机推荐
- ReactNative调试技术-真机调试
在我开始用ReactNative开始开发APP时,为了能够获取程序运行中的信息,就需要搭建调试环境. 手机调试方式有两类,一类是模拟器方式,另一类是真机模式. 我测试了一下相应的模拟器: 如果用谷歌管 ...
- 2016-06-19 exshop第5天
昨天对grails3和spring-security进行了全面的调研并进行了试验,试用下来发现grails3的启动速度.代码修改后刷新速度.内存占用以及架构的设计上更加合理,asset-pipelin ...
- Linux批量清空当前目录中的日志文件
在Linux中,有时需要批量清空当前目录中的日志文件,同时还要保留日志文件. 其实一行shell命令就可以搞定,一起来看看吧. 在当前目录下,键入如下命令: for i in `find . -nam ...
- ELK5.3日志分析平台&部署
https://www.cnblogs.com/xing901022/p/6030296.html ELK简介: Elasticsearch是个开源分布式搜索引擎,它的特点有:分布式,零配置,自动发现 ...
- mybatis的xml处理大于和小于号问题
https://blog.csdn.net/u022812849/article/details/42123007
- css图片根据div宽高比例自适应
1.div布局 <div class="card-img-show"> <div class="upload-img-conss" > ...
- h5 rem js自动适配
(function (doc, win) { var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? ...
- 【python】数据库
No1: [SQLite] 插入 # 导入SQLite驱动: >>> import sqlite3 # 连接到SQLite数据库 # 数据库文件是test.db # 如果文件不存在, ...
- poj3311
poj3311我写的第一篇状压dp,调试了好久23333,其实状压就是二进制结合位运算,把整体的状态用二进制来表示,一般是0/1,用没用过或者走没走没走过的问题,其实这种思想在搜索中也有涉及过,与dp ...
- JavaScript函数、闭包、原型、面向对象
JavaScript函数.闭包.原型.面向对象 断言 单元测试框架的核心是断言方法,通常叫assert(). 该方法通常接收一个值--需要断言的值,以及一个表示该断言目的的描述. 如果该值执行的结果为 ...