{"id":137,"date":"2013-05-23T21:38:38","date_gmt":"2013-05-23T13:38:38","guid":{"rendered":"http:\/\/coderbee.net\/?p=137"},"modified":"2013-05-23T16:40:26","modified_gmt":"2013-05-23T08:40:26","slug":"watch-%e5%91%a8%e6%9c%9f%e6%80%a7%e6%89%a7%e8%a1%8c%e7%bb%99%e5%ae%9a%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/coderbee.net\/index.php\/linux\/20130523\/137","title":{"rendered":"watch \u5468\u671f\u6027\u6267\u884c\u7ed9\u5b9a\u547d\u4ee4"},"content":{"rendered":"<h2>watch<\/h2>\n<p>\u5468\u671f\u6027\u5730\u6267\u884c\u7ed9\u5b9a\u7684\u547d\u4ee4\uff0c\u5e76\u5168\u5c4f\u8f93\u51fa\u547d\u4ee4\u6267\u884c\u7ed3\u679c\u3002\u53ef\u4ee5\u7528 <code>Ctrl-c<\/code> \u6765\u7ec8\u6b62watch\u547d\u4ee4\u3002<\/p>\n<h3>\u7528\u6cd5<\/h3>\n<p><code>watch  [-bdehpvtx]  [-n  seconds]  [--beep]  [--color]  [--defferences[cumulative]]  [--errexit]  [--exec]  [--help]  [--interval=seconds]  [--no-title]  [--precise]  [--version]  command<\/code><\/p>\n<p>command\u9ed8\u8ba4\u662f\u4ea4\u7ed9 <code>sh  -c<\/code> \u6267\u884c\u7684\uff0c\u6709\u65f6\u5019\u9700\u8981\u7528\u5f15\u53f7\u6765\u660e\u786e\u547d\u4ee4\u3002<\/p>\n<h3>\u9009\u9879<\/h3>\n<ul>\n<li><code>-n  seconds,  --interval=seconds<\/code>\uff1a\u6bcf\u9694\u6307\u5b9a\u7684\u79d2\u6267\u884c\u547d\u4ee4\u3002\u8fd9\u4e2a\u95f4\u9694\u662f\u6307\u547d\u4ee4\u4e0a\u4e00\u6b21\u7ed3\u675f\u5230\u4e0b\u4e00\u6b21\u5f00\u59cb\u6267\u884c\u4e4b\u95f4\u7684\u95f4\u9694\u3002\u9ed8\u8ba42\u79d2\u3002<\/li>\n<li><code>-p,  --precise<\/code>\uff1a\u8ba9watch\u5c1d\u8bd5\u6bcf\u9694\u6307\u5b9a\u7684\u79d2\u6267\u884c\u547d\u4ee4\uff0c\u8fd9\u6837\u95f4\u9694\u4e0d\u5305\u62ec\u6267\u884c\u547d\u4ee4\u6240\u7528\u65f6\u95f4\u3002\u53ea\u662f\u5c3d\u529b\u800c\u4e3a\u7684\u51c6\u786e\u3002<\/li>\n<li><code>-e,  --errexit<\/code>\uff1a\u547d\u4ee4\u6267\u884c\u51fa\u9519\uff08\u8fd4\u56de\u503c\u975e0\uff09\u65f6\u9000\u51fawatch\u547d\u4ee4\u3002<\/li>\n<li><code>-t,  --no-title<\/code>\uff1awatch\u4e0d\u5728\u9996\u884c\u663e\u793a\u6267\u884c\u95f4\u9694\u3001\u547d\u4ee4\u3001\u5f53\u524d\u65f6\u95f4\u548c\u540e\u9762\u7684\u7a7a\u884c\u3002<\/li>\n<li><code>-b,  --beep<\/code>\uff1a\u5982\u679ccommand\u6267\u884c\u8fd4\u56de\u503c\u975e0\uff0cbeep\u3002<\/li>\n<li><code>-d,  --defferences<\/code>\uff1a\u9ad8\u4eae\u4e24\u6b21\u6210\u529f\u6267\u884c\u7ed3\u679c\u4e4b\u95f4\u7684\u5dee\u5f02\u3002<\/li>\n<li><code>-x,  --exec<\/code>\uff1a\u628acommand\u4ea4\u7ed9 <code>exec<\/code> \u547d\u4ee4\u6267\u884c\u3002<\/li>\n<\/ul>\n<h3>\u4e3e\u4f8b<\/h3>\n<p><code>watch  -n  5  df  -h<\/code>\uff1a\u6bcf\u96945\u79d2\u67e5\u770b\u78c1\u76d8\u7684\u7a7a\u95f4\u5927\u5c0f\u3002<\/p>\n<p><code>watch  -d  ls  -l<\/code>\uff1a\u6bcf\u96942\u79d2\u9ad8\u4eae\u8f93\u51fa\u4e24\u6b21ls\u4e4b\u95f4\u7684\u5dee\u5f02\u3002<\/p>\n<p><code>watch  -d  'ls  -l  |  grep  text'<\/code>\uff1a\u6ce8\u610f\u5355\u5f15\u53f7\u7684\u4f7f\u7528\u3002<\/p>\n<p>\u6ce8\u610f<code>watch  -n  10  sleep  1<\/code> \u548c <code>watch -p -n 10 sleep 1<\/code>\u7684\u533a\u522b\uff0c\u524d\u8005\u6bcf\u969411\u79d2\u6267\u884c\u4e00\u6b21\uff0c\u540e\u8005\u6bcf\u969410\u79d2\u6267\u884c\u4e00\u6b21\uff0c<code>-p<\/code>\u9009\u9879\u5c3d\u91cf\u51cf\u53bb\u547d\u4ee4\u7684\u6267\u884c\u65f6\u95f4\u3002<\/p>\n<hr\/>\n<p>\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u5fae\u4fe1\u516c\u4f17\u53f7: <strong>coderbee\u7b14\u8bb0<\/strong>\uff0c\u53ef\u4ee5\u66f4\u53ca\u65f6\u56de\u590d\u4f60\u7684\u8ba8\u8bba\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"258\" src=\"https:\/\/coderbee.net\/wp-content\/uploads\/2019\/01\/coderbee-note.jpg\" class=\"alignnone size-full wp-image-1707\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>watch \u5468\u671f\u6027\u5730\u6267\u884c\u7ed9\u5b9a\u7684\u547d\u4ee4\uff0c\u5e76\u5168\u5c4f\u8f93\u51fa\u547d\u4ee4\u6267\u884c\u7ed3\u679c\u3002\u53ef\u4ee5\u7528 Ctrl-c &hellip; <a href=\"https:\/\/coderbee.net\/index.php\/linux\/20130523\/137\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[29],"_links":{"self":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/137"}],"collection":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/comments?post=137"}],"version-history":[{"count":2,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/137\/revisions"}],"predecessor-version":[{"id":139,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/137\/revisions\/139"}],"wp:attachment":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/media?parent=137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/categories?post=137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/tags?post=137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}