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之变量替换::=句法.=句法.:-句法.-句法. ...
随机推荐
- [arc066f]Contest with Drinks Hard
题目大意: 有一些物品,每个买了有代价. 如果存在一个极大区间[l,r]内的物品都被买了,这个区间长度为k,可以获得的收益是k*(k+1)/2. 现在若干次询问,每次问假如修改了某个物品的价格,最大收 ...
- [HNOI2007]梦幻岛宝珠
题解: 一道比较好的题目 首先比较显然的就是我们要按照a*2^b的b的顺序来枚举 那么状态f[i][j]表示当前在b,用了a*2^b 刚开始没想到怎么不同层之间搞 看了题解发现非常简单 由于每一层到最 ...
- Azure 国内版 如何用powershell修改linux系统的密码
国内版不像国际版本那样,一个UI按钮就解决问题,国内版很多功能上线比较慢,我们只能用powershell工具进行命令行 式的更改,也当温习一下命令了,好久不用了. $vm = Get-AzureVM ...
- mysql字符集问题汇总
1.设置mysql字符集:在my.ini中添加以下设置,没有my.ini可以将my_default.ini改成他.character-set-server=utf8[client]loose-defa ...
- Spring Boot之 Controller 接收参数和返回数据总结(包括上传、下载文件)
一.接收参数(postman发送) 1.form表单 @RequestParam("name") String name 会把传递过来的Form表单中的name对应 ...
- tomcat-会话绑定
会话保存 1) session sticky source_ip 原地址绑定 nginx: ip_hash haproxy: source lvs: ...
- P1040 加分二叉树 区间dp
题目描述 设一个nn个节点的二叉树tree的中序遍历为(1,2,3,…,n1,2,3,…,n),其中数字1,2,3,…,n1,2,3,…,n为节点编号.每个节点都有一个分数(均为正整数),记第ii个节 ...
- 五种UML工具
ProcessOn是一款在线流程图软件(https://www.processon.com/),能够高效的完成在线流程图.UI原型图.UML以及组织图,网络拓扑图的构建.该软件最大的特点是,无需安装, ...
- POJ 2912 Rochambeau(暴力)+【带权并查集】
<题目链接> 题目大意: n个人进行m轮剪刀石头布游戏(0<n<=500,0<=m<=2000),接下来m行形如x, y, ch的输入,ch='='表示x, y平局 ...
- 服务端线程模型-NIO服务模型
上接<服务端线程模型-线程池服务模型>(https://www.cnblogs.com/fudashi233/p/10549221.html). 这篇分享从最初的单线程服务模型一直演进到线 ...