Centos下为程序如何设置超时
添加时间:2019-10-30 8:19:48
添加:
思海网络
timeout 是个奇妙的Linux命令,它可以控制程序运行的时间,这对于我们希望控制程序的运行时间非常有用。
timeout在CentOS 6平台上,从属于软件包coreutils
# which timeout
/usr/bin/timeout
# rpm -qf /usr/bin/timeout
coreutils-8.4-19.el6_4.2.x86_64
timeout的原理很简单,一个简单的计时器,一个kill命令,其中-s 可以跟kill的参数,具体怎么杀,就看它。
man timeout仅仅半页,如下
TIMEOUT(1) User Commands TIMEOUT(1)
NAME
timeout - run a commandwith a timelimit
SYNOPSIS
timeout [OPTION] NUMBER[SUFFIX] COMMAND [ARG]...
timeout [OPTION]
DEION
Start COMMAND, and killit ifstill running after NUMBER seconds. SUFFIX may be ‘s’forseconds (the default), ‘m’ forminutes, ‘h’
forhours or ‘d’ fordays.
Mandatory arguments to long options are mandatory forshort options too.
-s, --signal=SIGNAL
specify the signal to be sent on timeout. SIGNAL may be a name like ‘HUP’ or a number. See ‘kill-l‘ fora list of signals
--help display this help and exit
--version
output version information and exit
If the commandtimesout, thenexitwith status 124. Otherwise, exitwith the status of COMMAND. If no signal is specified, send the
TERM signal upon timeout. The TERM signal kills any process that does not block or catch that signal. For other processes, it may be
necessary to use the KILL (9) signal, since this signal cannot be caught.
AUTHOR
Written by Padraig Brady.
用法举例
1timeout 120 command
上面的command命令如果在120秒内完成,则平安结束,运行超过120秒后将被杀死。
关键字:Centos、程序、超时
新文章:
- CentOS7下图形配置网络的方法
- CentOS 7如何添加删除用户
- 如何解决centos7双系统后丢失windows启动项
- CentOS单网卡如何批量添加不同IP段
- CentOS下iconv命令的介绍
- Centos7 SSH密钥登陆及密码密钥双重验证详解
- CentOS 7.1添加删除用户的方法
- CentOS查找/扫描局域网打印机IP讲解
- CentOS7使用hostapd实现无AP模式的详解
- su命令不能切换root的解决方法
- 解决VMware下CentOS7网络重启出错
- 解决Centos7双系统后丢失windows启动项
- CentOS下如何避免文件覆盖
- CentOS7和CentOS6系统有什么不同呢
- Centos 6.6默认iptable规则详解