Centos下為程序如何設(shè)置超時
添加時間:2019-10-30 8:19:48
添加:
思海網(wǎng)絡(luò)
timeout 是個奇妙的Linux命令,它可以控制程序運(yùn)行的時間,這對于我們希望控制程序的運(yùn)行時間非常有用。
timeout在CentOS 6平臺上,從屬于軟件包c(diǎn)oreutils
# which timeout
/usr/bin/timeout
# rpm -qf /usr/bin/timeout
coreutils-8.4-19.el6_4.2.x86_64
timeout的原理很簡單,一個簡單的計時器,一個kill命令,其中-s 可以跟kill的參數(shù),具體怎么殺,就看它。
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秒內(nèi)完成,則平安結(jié)束,運(yùn)行超過120秒后將被殺死。
關(guān)鍵字:Centos、程序、超時
新文章:
- CentOS7下圖形配置網(wǎng)絡(luò)的方法
- CentOS 7如何添加刪除用戶
- 如何解決centos7雙系統(tǒng)后丟失windows啟動項
- CentOS單網(wǎng)卡如何批量添加不同IP段
- CentOS下iconv命令的介紹
- Centos7 SSH密鑰登陸及密碼密鑰雙重驗證詳解
- CentOS 7.1添加刪除用戶的方法
- CentOS查找/掃描局域網(wǎng)打印機(jī)IP講解
- CentOS7使用hostapd實現(xiàn)無AP模式的詳解
- su命令不能切換root的解決方法
- 解決VMware下CentOS7網(wǎng)絡(luò)重啟出錯
- 解決Centos7雙系統(tǒng)后丟失windows啟動項
- CentOS下如何避免文件覆蓋
- CentOS7和CentOS6系統(tǒng)有什么不同呢
- Centos 6.6默認(rèn)iptable規(guī)則詳解