{"id":7956,"date":"2020-06-13T15:24:01","date_gmt":"2020-06-13T07:24:01","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=7956"},"modified":"2020-06-13T15:24:02","modified_gmt":"2020-06-13T07:24:02","slug":"timeout","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/timeout","title":{"rendered":"timeout\u547d\u4ee4 – \u5728\u6307\u5b9a\u7684\u65f6\u95f4\u5e94\u5728\u8fd0\u884c\u5219\u6740\u6b7b\u8be5\u8fdb\u7a0b"},"content":{"rendered":"\n

timeout\u547d\u4ee4\u4f5c\u7528\u662f\u8fd0\u884c\u6307\u5b9a\u547d\u4ee4\uff0c\u5982\u679c\u5728\u6307\u5b9a\u65f6\u95f4\u540e\u5728\u8fd0\u884c\u5219\u6740\u6b7b\u8be5\u8fdb\u7a0b\u3002<\/p>\n\n\n\n

timeout\u547d\u4ee4\u662fGNU\u6838\u5fc3\u5b9e\u7528\u7a0b\u5e8f\u8f6f\u4ef6\u5305\u7684\u4e00\u90e8\u5206\uff0c\u8be5\u8f6f\u4ef6\u5305\u51e0\u4e4e\u5b89\u88c5\u5728\u6240\u6709Linux\u53d1\u884c\u7248\u4e2d\u3002\u540e\u7f00s\u4ee3\u8868\u79d2\uff08\u9ed8\u8ba4\u503c\uff09\uff0cm\u4ee3\u8868\u5206\uff0ch\u4ee3\u8868\u5c0f\u65f6\uff0cd\u4ee3\u8868\u5929\u3002\u5982\u679c\u4e0d\u6dfb\u52a0\u4efb\u4f55\u5355\u4f4d\uff0c\u9ed8\u8ba4\u662f\u79d2\u3002\u5982\u679c\u6301\u7eed\u65f6\u95f4\u4e3a0\uff0c\u5219\u7981\u7528\u5173\u8054\u7684\u8d85\u65f6\u3002<\/p>\n\n\n\n

\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0ctimeout\u5728\u540e\u53f0\u8fd0\u884c\u6258\u7ba1\u547d\u4ee4\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>timeout [\u53c2\u6570]<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n

-s<\u4fe1\u53f7><\/td>\u6307\u5b9a\u5728\u8d85\u65f6\u65f6\u53d1\u9001\u7684\u4fe1\u53f7\uff0c\u4fe1\u53f7\u53ef\u4ee5\u662f\u7c7b\u4f3c\u201cHUP\u201d\u7684\u4fe1\u53f7\u540d\u6216\u662f\u4fe1\u53f7\u6570<\/td><\/tr>
-k<\u65f6\u95f4><\/td>\u8fbe\u5230\u7ed9\u5b9a\u7684\u65f6\u95f4\u9650\u5236\u540e\u4f1a\u5f3a\u5236\u7ed3\u675f<\/td><\/tr>
-- -foreground<\/td>\u5728\u524d\u53f0\u8fd0\u884c<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u53d1\u9001SIGKILL\u4fe1\u53f7\u7ed9ping\u547d\u4ee4\uff0c5\u79d2\u949f\u540e\u7ec8\u6b62\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# timeout -s SIGKILL 5s ping www.linuxprobe.com<\/pre>\n\n\n\n

\u8fd0\u884c\u547d\u4ee4\u4e00\u5206\u949f\uff0c\u5982\u679c\u547d\u4ee4\u6ca1\u6709\u7ed3\u675f\uff0c\u5c06\u572810\u79d2\u540e\u7ec8\u6b62\u547d\u4ee4\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# timeout -k 10s 1m sh linuxcool.sh<\/pre>\n\n\n\n

\u5728\u524d\u53f0\u8fd0\u884c\u547d\u4ee4\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# timeout --foreground 5m .\/linuxcool.sh<\/pre>\n","protected":false},"excerpt":{"rendered":"

timeout\u547d\u4ee4\u4f5c\u7528\u662f\u8fd0\u884c\u6307\u5b9a\u547d\u4ee4\uff0c\u5982\u679c\u5728\u6307\u5b9a\u65f6\u95f4\u540e\u5728\u8fd0\u884c\u5219\u6740\u6b7b\u8be5\u8fdb\u7a0b\u3002 timeout\u547d\u4ee4\u662fGNU\u6838\u5fc3\u5b9e\u7528 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/7956"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=7956"}],"version-history":[{"count":4,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/7956\/revisions"}],"predecessor-version":[{"id":7968,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/7956\/revisions\/7968"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=7956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=7956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=7956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}