国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > CentOS > 正文

Centos下為程序如何設置超時?Centos下為程序設置超時的方法

2020-07-08 12:48:03
字體:
來源:轉載
供稿:網友

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]

DESCRIPTION

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秒后將被殺死。

腳本經常是傻乎乎的一口氣跑到完,搞得我們需要寫另一個腳本定期去殺它。自打有了timeout命令,腰也不疼了,腿也不酸了,跑跑歇歇更健康。

一句話,我們在腳本里或者crontab里就不用再造輪子了。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 德安县| 正蓝旗| 北辰区| 大连市| 白城市| 勃利县| 玉田县| 麟游县| 宜黄县| 静乐县| 麻城市| 博湖县| 安图县| 姜堰市| 中方县| 来宾市| 洛阳市| 方城县| 宜阳县| 奈曼旗| 中西区| 寿阳县| 永仁县| 分宜县| 安岳县| 绍兴县| 甘德县| 江达县| 郸城县| 仁怀市| 台中县| 青州市| 灵武市| 泗洪县| 山西省| 古田县| 汪清县| 泸水县| 英山县| 扶风县| 霍邱县|