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之变量替换::=句法.=句法.:-句法.-句法. ...
随机推荐
- ELK安装(ubuntu)
一.安装jdk8 经过我测试logstash5.x不支持java10和11,所以安装java8 加入LinuxUprising Java PPA sudo add-apt-repository ppa ...
- 20165235 2017-2018-2《Java程序设计》课程总结
20165235 2017-2018-2<Java程序设计>课程总结 每周作业链接汇总 预备作业一 预备作业二 预备作业三 第一周学习总结 第二周学习总结 第三周学习总结 第四周学习总结 ...
- 1、Qt Project之基本文件打开与保存
基本文件打开与保存: 首先是涉及到的头文件,我们需要在mainwindow.h包含头文件: #include <QFileDialog> #include <QFile> #i ...
- 用sql的avg(score)求完平均值后,保存两位小数的方法(用于查询或视图)
查jx_score表的平均值,以哪次考试(testid)和科目分组(courseid) select testid, courseid, round(avg(`jx_score`.`score`),2 ...
- eclipse里面svn比较之前版本的代码
team——显示资源历史记录比较
- Codeforces 1082D Maximum Diameter Graph (贪心构造)
<题目链接> 题目大意:给你一些点的最大度数,让你构造一张图,使得该图的直径最长,输出对应直径以及所有的边. 解题分析:一道比较暴力的构造题,首先,我们贪心的想,要使图的直径最长,肯定是尽 ...
- Django 学习第三天——模板变量及模板过滤器
一.模板路径的查找: 查找顺序:(现在哪找到就用那个) 首先在主目录的 setting.py 文件里的 TEMPLATES 中的 DIRS 里找: 其次如果 DIRS 中的 APP_DIRS : 'T ...
- basename
我使用过的Linux命令之basename - 去掉文件名的目录和后缀 本文链接:http://codingstandards.iteye.com/blog/840784 (转载请注明出处) 用途 ...
- 调整和删除Win7休眠文件Hiberfil.sys释放C盘
Hiberfil.sys 是 Windows 休眠功能(Windows Hibernation)将内存数据与会话保存至硬盘.以便计算机断电重新启动后可以快速恢复会话所需的内存镜像文件.在早期版本的 W ...
- Linux学习笔记10
创建文件 touch touch filenames 创建文件夹 mkdir mkdir dir3 dir4 dir5 建立多个文件夹 mkdir ~/games 在登录用户的本目录之下建立game ...