{"id":2913,"date":"2017-11-30T14:00:19","date_gmt":"2017-11-30T06:00:19","guid":{"rendered":"http:\/\/cn.hostease.com\/xueyuan\/?p=2913"},"modified":"2017-11-30T14:00:19","modified_gmt":"2017-11-30T06:00:19","slug":"inotifyrsync%e5%ae%9e%e7%8e%b0%e5%ae%9e%e6%97%b6%e5%90%8c%e6%ad%a5","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/xueyuan\/jishu\/linux\/inotifyrsync%e5%ae%9e%e7%8e%b0%e5%ae%9e%e6%97%b6%e5%90%8c%e6%ad%a5\/","title":{"rendered":"inotify+rsync\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65"},"content":{"rendered":"<h2>\u7b2c1\u7ae0 \u6570\u636e\u5b9e\u65f6\u540c\u6b65\u4ecb\u7ecd<\/h2>\n<h3>1.1 \u4ec0\u4e48\u662f\u5b9e\u65f6\u540c\u6b65\uff1a\u5982\u4f55\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65<\/h3>\n<p>A.\u00a0\u8981\u5229\u7528\u76d1\u63a7\u670d\u52a1\uff08inotify\uff09\uff0c\u76d1\u63a7\u540c\u6b65\u6570\u636e\u670d\u52a1\u5668\u76ee\u5f55\u4e2d\u4fe1\u606f\u7684\u53d8\u5316<\/p>\n<p>B.\u00a0\u53d1\u73b0\u76ee\u5f55\u4e2d\u6570\u636e\u4ea7\u751f\u53d8\u5316\uff0c\u5c31\u5229\u7528rsync\u670d\u52a1\u63a8\u9001\u5230\u5907\u4efd\u670d\u52a1\u5668\u4e0a<\/p>\n<h3>1.2 \u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65\u7684\u65b9\u6cd5<\/h3>\n<p>inotify+rsync \u65b9\u5f0f\u5b9e\u73b0\u6570\u636e\u540c\u6b65<\/p>\n<p>sersync \u65b9\u5f0f\u5b9e\u73b0\u5b9e\u65f6\u6570\u636e\u540c\u6b65<\/p>\n<h4>1.2.1 \u5b9e\u65f6\u540c\u6b65\u539f\u7406\u4ecb\u7ecd<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.linuxidc.com\/upload\/2017_11\/17112412002044.jpg\" alt=\"\" width=\"706\" align=\"middle\" vspace=\"5\" \/><\/p>\n<h3>1.3 inotify+rsync \u65b9\u5f0f\u5b9e\u73b0\u6570\u636e\u540c\u6b65<\/h3>\n<h4>1.3.1 Inotify\u7b80\u4ecb<\/h4>\n<p>Inotify\u662f\u4e00\u79cd\u5f3a\u5927\u7684\uff0c\u7ec6\u7c92\u5ea6\u7684\u3002\u5f02\u6b65\u7684\u6587\u4ef6\u7cfb\u7edf\u4e8b\u4ef6\u76d1\u63a7\u673a\u5236\uff0clinux\u5185\u6838\u4ece2.6.13\u8d77\uff0c\u52a0\u5165\u4e86 Inotify\u652f\u6301\uff0c\u901a\u8fc7Inotify\u53ef\u4ee5\u76d1\u63a7\u6587\u4ef6\u7cfb\u7edf\u4e2d\u6dfb\u52a0\u3001\u5220\u9664\uff0c\u4fee\u6539\u3001\u79fb\u52a8\u7b49\u5404\u79cd\u4e8b\u4ef6,\u5229\u7528\u8fd9\u4e2a\u5185\u6838\u63a5\u53e3\uff0c\u7b2c\u4e09\u65b9\u8f6f\u4ef6\u5c31\u53ef\u4ee5\u76d1\u63a7\u6587\u4ef6\u7cfb\u7edf\u4e0b\u6587\u4ef6\u7684\u5404\u79cd\u53d8\u5316\u60c5\u51b5\uff0c\u800c <strong>inotify-tools<\/strong> \u6b63\u662f\u5b9e\u65bd\u8fd9\u6837\u76d1\u63a7\u7684\u8f6f\u4ef6\u3002\u56fd\u4eba\u5468\u6d0b\u5728\u91d1\u5c71\u516c\u53f8\u4e5f\u5f00\u53d1\u4e86\u7c7b\u4f3c\u7684\u5b9e\u65f6\u540c\u6b65\u8f6f\u4ef6sersync\u3002<\/p>\n<div>\n<p>\u63d0\u793a\u4fe1\u606f\uff1a<\/p>\n<p>sersync\u8f6f\u4ef6\u5b9e\u9645\u4e0a\u5c31\u662f\u5728 inotify\u8f6f\u4ef6\u57fa\u7840\u4e0a\u8fdb\u884c\u5f00\u53d1\u7684\uff0c\u529f\u80fd\u8981\u66f4\u52a0\u5f3a\u5927\u4e9b \uff0c\u591a\u4e86\u5b9a\u65f6\u91cd\u4f20\u673a\u5236\uff0c\u8fc7\u6ee4\u673a\u5236\u4e86\u63d0\u4f9b\u63a5\u53e3\u505a CDN\uff0c\u652f\u6301\u591a\u7ebf\u7a0b\u6a7e\u4f5c\u3002<\/p>\n<\/div>\n<p>Inotify\u5b9e\u9645\u662f\u4e00\u79cd\u4e8b\u4ef6\u9a71\u52a8\u673a\u5236\uff0c\u5b83\u4e3a\u5e94\u7528\u7a0b\u5e8f\u76d1\u63a7\u6587\u4ef6\u7cfb\u7edf\u4e8b\u4ef6\u63d0\u4f9b\u4e86\u5b9e\u65f6\u54cd\u5e94\u4e8b\u4ef6\u7684\u673a\u5236\uff0c\u800c\u65e0\u987b\u901a\u8fc7\u8bf8\u5982cron\u7b49\u7684\u8f6e\u8be2\u673a\u5236\u6765\u83b7\u53d6\u4e8b\u4ef6\u3002cron\u7b49\u673a\u5236\u4e0d\u4ec5\u65e0\u6cd5\u505a\u5230\u5b9e\u65f6\u6027\uff0c\u800c\u4e14\u6d88\u8017\u5927\u91cf\u7cfb\u7edf\u8d44\u6e90\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0cinotify\u57fa\u4e8e\u4e8b\u4ef6\u9a71\u52a8\uff0c\u53ef\u4ee5\u505a\u5230\u5bf9\u4e8b\u4ef6\u5904\u7406\u7684\u5b9e\u65f6\u54cd\u5e94\uff0c\u4e5f\u6ca1\u6709\u8f6e\u8be2\u9020\u6210\u7684\u7cfb\u7edf\u8d44\u6e90\u6d88\u8017\uff0c\u662f\u975e\u5e38\u81ea\u7136\u7684\u4e8b\u4ef6\u901a\u77e5\u63a5\u53e3\uff0c\u4e5f\u4e0e\u81ea\u7136\u4e16\u754c\u4e8b\u4ef6\u673a\u5236\u76f8\u7b26\u5408\u3002<\/p>\n<p>inotify\u7684\u5b9e\u73b0\u6709\u51e0\u6b3e\u8f6f\u4ef6\uff1a<\/p>\n<div class=\"linuxidc_code\">\n<pre>inotify-tools\uff0csersync\uff0clrsyncd<\/pre>\n<\/div>\n<h4>1.3.2 inotify+rsync\u4f7f\u7528\u65b9\u5f0f<\/h4>\n<p>inotify \u5bf9\u540c\u6b65\u6570\u636e\u76ee\u5f55\u4fe1\u606f\u7684\u76d1\u63a7<\/p>\n<p>rsync\u00a0 \u5b8c\u6210\u5bf9\u6570\u636e\u4fe1\u606f\u7684\u5b9e\u65f6\u540c\u6b65<\/p>\n<p>\u5229\u7528\u811a\u672c\u8fdb\u884c\u7ed3\u5408<\/p>\n<h3>1.4 \u90e8\u7f72inotify\u8f6f\u4ef6\u7684\u524d\u63d0<\/h3>\n<p>\u9700\u89812.6.13\u4ee5\u540e\u5185\u6838\u7248\u672c\u624d\u80fd\u652f\u6301inotify\u8f6f\u4ef6\u30022.6.13\u5185\u6838\u4e4b\u540e\u7248\u672c\uff0c\u5728\u6ca1\u6709\u5b89\u88c5inotify\u8f6f\u4ef6\u4e4b\u524d\uff0c\u5e94\u8be5\u6709\u8fd9\u4e09\u4e2a\u6587\u4ef6\u3002<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@backup ~]# ll \/proc\/sys\/fs\/inotify\/\r\ntotal 0\r\n-rw-r--r-- 1 root root 0 Oct 17 10:12 max_queued_events\r\n-rw-r--r-- 1 root root 0 Oct 17 10:12 max_user_instances\r\n-rw-r--r-- 1 root root 0 Oct 17 10:12 max_user_watches<\/pre>\n<\/div>\n<h4>1.4.1 \u4e09\u4e2a\u91cd\u8981\u6587\u4ef6\u7684\u8bf4\u660e<\/h4>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"187\">\n<p align=\"center\"><strong>\u6587\u4ef6<\/strong><\/p>\n<\/td>\n<td width=\"77\">\n<p align=\"center\"><strong>\u9ed8\u8ba4\u503c<\/strong><\/p>\n<\/td>\n<td width=\"433\">\n<p align=\"center\"><strong>\u4f5c\u7528\u8bf4\u660e<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"187\">max_user_watches<\/td>\n<td width=\"77\">8192<\/td>\n<td width=\"433\">\u8bbe\u7f6einotifywait\u6216inotifywatch\u547d\u4ee4\u53ef\u4ee5\u76d1\u89c6\u7684\u6587\u4ef6\u6570\u91cf\uff08\u5355\u8fdb\u7a0b\uff09<\/td>\n<\/tr>\n<tr>\n<td width=\"187\">max_user_instances<\/td>\n<td width=\"77\">128<\/td>\n<td width=\"433\">\u8bbe\u7f6e\u6bcf\u4e2a\u7528\u6237\u53ef\u4ee5\u8fd0\u884c\u7684inotifywait\u6216inotifywatch\u547d\u4ee4\u7684\u8fdb\u7a0b\u6570<\/td>\n<\/tr>\n<tr>\n<td width=\"187\">max_queued_events<\/td>\n<td width=\"77\">16384<\/td>\n<td width=\"433\">\u8bbe\u7f6einotify\u5b9e\u4f8b\u4e8b\u4ef6\uff08event\uff09\u961f\u5217\u53ef\u5bb9\u7eb3\u7684\u4e8b\u4ef6\u6570\u91cf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1.4.2 \u3010\u670d\u52a1\u4f18\u5316\u3011\u53ef\u4ee5\u5c06\u4e09\u4e2a\u6587\u4ef6\u7684\u6570\u503c\u8c03\u5927\uff0c\u76d1\u542c\u66f4\u5927\u7684\u8303\u56f4<\/h4>\n<h4>1.4.3 \u3010\u5b98\u65b9\u8bf4\u660e\u3011\u4e09\u4e2a\u91cd\u8981\u6587\u4ef6<\/h4>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 ~]# man proc\r\n\/proc\/sys\/fs\/inotify (since Linux 2.6.13)\r\n       This   directory   contains    files    max_queued_events,\r\n       max_user_instances, and max_user_watches, that can be used\r\n       to limit the amount of kernel memory consumed by the  inotify interface. \r\nfor further details, see inotify(7).<\/pre>\n<\/div>\n<div>\n<p>\u901a\u8fc7man\u624b\u518c\u7684\u7b2c7\u7ea7\u522b\u4e2d\u67e5\u5230 inotify\u7684\u9ed8\u8ba4\u6587\u4ef6\u7684\u8be6\u7ec6\u8bf4\u660e\u3002<\/p>\n<\/div>\n<div class=\"linuxidc_code\">\n<div class=\"linuxidc_code_toolbar\"><\/div>\n<pre>[root@nfs01 ~]# man 7 inotify\r\n\/proc\/sys\/fs\/inotify\/max_queued_events\r\n       The  value  in this file is used when an application calls\r\n       inotify_init(2) to set an upper limit  on  the  number  of\r\n       events  that  can  be  queued to the corresponding inotify\r\n       instance.  Events in excess of this limit are dropped, but\r\n       an IN_Q_OVERFLOW event is always generated.\r\n \r\n\/proc\/sys\/fs\/inotify\/max_user_instances\r\n       This  specifies  an  upper  limit on the number of inotify\r\n       instances that can be created per real user ID.\r\n \r\n\/proc\/sys\/fs\/inotify\/max_user_watches\r\n       This specifies an upper limit on  the  number  of  watches\r\n       that can be created per real user ID.<\/pre>\n<\/div>\n<h3>1.5 inotify\u8f6f\u4ef6\u4ecb\u7ecd\u53ca\u53c2\u6570\u8bf4\u660e<\/h3>\n<h4>1.5.1 \u4e24\u79cd\u5b89\u88c5\u65b9\u5f0f<\/h4>\n<div>\n<p>1\uff09 yum install -y inotify-tools<\/p>\n<p>2\uff09 \u624b\u5de5\u7f16\u8bd1\u5b89\u88c5<\/p>\n<\/div>\n<p>\u6ce8\uff1a<\/p>\n<p>YUM \u5b89\u88c5\u9700\u8981\u6709epel\u6e90<\/p>\n<div class=\"linuxidc_code\">\n<pre>https:\/\/mirrors.aliyun.com<\/pre>\n<\/div>\n<p>\u624b\u5de5\u7f16\u8bd1\u5b89\u88c5\u65b9\u5f0f\u9700\u8981\u5230github\u4e0a\u8fdb\u884c\u4e0b\u8f7d\u8f6f\u4ef6\u5305<\/p>\n<p>inotify\u8f6f\u4ef6\u7684\u53c2\u8003\u8d44\u6599\u94fe\u63a5\uff1a<\/p>\n<div class=\"linuxidc_code\">\n<pre>https:\/\/github.com\/rvoicilas\/inotify-tools\/wiki<\/pre>\n<\/div>\n<h4>1.5.2 inotify\u4e3b\u8981\u5b89\u88c5\u7684\u4e24\u4e2a\u8f6f\u4ef6<\/h4>\n<div>\n<p><strong>inotifywait<\/strong><strong>\uff1a <\/strong><strong>\uff08\u4e3b\u8981\uff09<\/strong><\/p>\n<p>\u5728\u88ab\u76d1\u63a7\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4e0a\u7b49\u5f85\u7279\u5b9a\u6587\u4ef6\u7cfb\u7edf\u4e8b\u4ef6\uff08open close delete\u7b49\uff09\u53d1\u751f\uff0c\u6267\u884c\u540e\u5904\u4e8e\u963b\u585e\u72b6\u6001\uff0c\u9002\u5408\u5728shell\u811a\u672c\u4e2d\u4f7f\u7528<\/p>\n<p>inotifywatch\uff1a<\/p>\n<p>\u6536\u96c6\u88ab\u76d1\u63a7\u7684\u6587\u4ef6\u7cfb\u7edf\u4f7f\u7528\u7684\u7edf\u8ba1\u6570\u636e\uff0c\u6307\u6587\u4ef6\u7cfb\u7edf\u4e8b\u4ef6\u53d1\u751f\u7684\u6b21\u6570\u7edf\u8ba1\u3002<\/p>\n<\/div>\n<p>\u8bf4\u660e\uff1a\u5728\u5b9e\u65f6\u5b9e\u65f6\u540c\u6b65\u7684\u65f6\u5019\uff0c\u4e3b\u8981\u662f\u5229\u7528inotifywait\u5bf9\u76ee\u5f55\u8fdb\u884c\u76d1\u63a7<\/p>\n<h4>1.5.3 inotifywait\u547d\u4ee4\u53c2\u6570\u8bf4\u660e<\/h4>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"217\">\n<p align=\"center\"><strong>\u53c2\u6570<\/strong><\/p>\n<\/td>\n<td width=\"480\">\n<p align=\"center\"><strong>\u542b\u4e49<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">-m, &#8211;monitor<\/p>\n<p><strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"480\">Keep listening for events forever.\u00a0 Without this option, inotifywait will exit after one event is received.<\/p>\n<p>\u59cb\u7ec8\u4fdd\u6301\u4e8b\u4ef6\u76d1\u542c\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">-d, &#8211;daemon<\/td>\n<td width=\"480\">111<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">-r, &#8211;recursive<\/p>\n<p><strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"480\">Watch all subdirectories of any directories passed as arguments.<\/p>\n<p>\u9012\u5f52\u76d1\u63a7\u76ee\u5f55\u6570\u636e\u4fe1\u606f\u53d8\u5316<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">-o, &#8211;outfile &lt;file&gt;<\/td>\n<td width=\"480\">Print events to &lt;file&gt; rather than stdout.<\/p>\n<p>\u6253\u5370\u4e8b\u4ef6\u5230\u6587\u4ef6\u4e2d\uff0c\u76f8\u5f53\u4e8e\u6807\u51c6\u6b63\u786e\u8f93\u51fa<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">-s, &#8211;syslog<\/td>\n<td width=\"480\">Output errors to syslog(3) system log module rather than stderr.<\/p>\n<p>\u53d1\u9001\u9519\u8bef\u5230syslog\u76f8\u5f53\u4e8e\u6807\u51c6\u9519\u8bef\u8f93\u51fa<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">-q, &#8211;quiet<\/p>\n<p><strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"480\">If specified once, the program will be less verbose.\u00a0 Specifically, it will not state\u00a0 when\u00a0 it\u00a0 has\u00a0 completed establishing all inotify watches.<\/p>\n<p>\u8f93\u51fa\u4fe1\u606f\u5c11\uff08\u53ea\u6253\u5370\u4e8b\u4ef6\u4fe1\u606f\uff09<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">&#8211;exclude &lt;pattern&gt;<\/td>\n<td width=\"480\">Exclude all events on files matching the extended regular expression &lt;pattern&gt;.<\/p>\n<p>\u6392\u9664\u6587\u4ef6\u6216\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">&#8211;excludei &lt;pattern&gt;<\/td>\n<td width=\"480\">Like &#8211;exclude but case insensitive.<\/p>\n<p>\u6392\u9664\u6587\u4ef6\u6216\u76ee\u5f55\u65f6\uff0c\u4e0d\u533a\u5206\u5927\u5c0f\u5199<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">&#8211;timefmt &lt;fmt&gt;<\/p>\n<p><strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"480\">Print using a specified printf-like format string; read the man page for more details.<\/p>\n<p>\u6307\u5b9a\u65f6\u95f4\u8f93\u51fa\u683c\u5f0f<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">&#8211;format &lt;fmt&gt;<\/p>\n<p><strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"480\">Print using a specified printf-like formatstring; read the man page for more details.<\/p>\n<p>\u6253\u5370\u4f7f\u7528\u6307\u5b9a\u7684\u8f93\u51fa\u7c7b\u4f3c\u683c\u5f0f\u5b57\u7b26\u4e32\uff1b\u5373\u5b9e\u9645\u76d1\u63a7\u8f93\u51fa\u5185\u5bb9<\/td>\n<\/tr>\n<tr>\n<td width=\"217\"><strong>-e<\/strong><\/p>\n<p><strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"480\">Listen for specific event(s).\u00a0 If omitted, all events are listened for.<\/p>\n<p>\u6307\u5b9a\u76d1\u542c\u6307\u5b9a\u7684\u4e8b\u4ef6\uff0c\u5982\u679c\u7701\u7565\uff0c\u8868\u793a\u6240\u6709\u4e8b\u4ef6\u90fd\u8fdb\u884c\u76d1\u542c<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\" width=\"697\">\u4ee5\u4e0a\u7684\u4fe1\u606f\u53ef\u4ee5\u901a\u8fc7 inotifywait &#8211;help\u00a0 \u83b7\u5f97<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1.5.4 -e[\u53c2\u6570] \u00a0\u53ef\u4ee5\u6307\u5b9a\u7684\u4e8b\u4ef6\u7c7b\u578b<\/h4>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"141\">\n<p align=\"center\"><strong>\u4e8b\u4ef6\u540d\u79f0<\/strong><\/p>\n<\/td>\n<td width=\"556\">\n<p align=\"center\"><strong>\u4e8b\u4ef6\u8bf4\u660e<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">access<\/td>\n<td width=\"556\">file or directory contents were read<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u5185\u5bb9\u88ab\u8bfb\u53d6<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">modify<\/td>\n<td width=\"556\">file or directory contents were writterv<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u5185\u5bb9\u88ab\u5199\u5165<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">attrib<\/td>\n<td width=\"556\">file or directory attributes changed<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u5c5e\u6027\u6539\u53d8<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">close_write<\/p>\n<p><strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"556\">file or directory closed, after being opened in writeable mode.<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u5173\u95ed\uff0c\u5728\u5199\u5165\u6a21\u5f0f\u6253\u5f00\u4e4b\u540e\u5173\u95ed\u7684\u3002<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">close_nowrite<\/td>\n<td width=\"556\">file or directory closed, after being opened in read-only mode.<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u5173\u95ed\uff0c\u5728\u53ea\u8bfb\u6a21\u5f0f\u6253\u5f00\u4e4b\u540e\u5173\u95ed\u7684<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">close<\/td>\n<td width=\"556\">file or directory closed, regardless of read\/write mode<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u5173\u95ed\uff0c\u4e0d\u7ba1\u8bfb\u6216\u662f\u5199\u6a21\u5f0f<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">open<\/td>\n<td width=\"556\">file or directory opened<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u88ab\u6253\u5f00<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">moved_to<\/p>\n<p>\u62c9<\/td>\n<td width=\"556\">file or directory moved to watched directory<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u88ab\u79fb\u52a8\u5230\u76d1\u63a7\u7684\u76ee\u5f55\u4e2d<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"141\">moved_from<\/p>\n<p>\u63a8<\/td>\n<td valign=\"top\" width=\"556\">file or directory moved from watched directory<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u88ab\u79fb\u52a8\u4ece\u76d1\u63a7\u7684\u76ee\u5f55\u4e2d<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"141\">move<\/p>\n<p><strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td valign=\"top\" width=\"556\">file or directory moved to or from watched directory<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u4e0d\u7ba1\u79fb\u52a8\u5230\u6216\u662f\u79fb\u51fa\u76d1\u63a7\u76ee\u5f55\u90fd\u89e6\u53d1\u4e8b\u4ef6<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"141\">create<\/p>\n<p><strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td valign=\"top\" width=\"556\">file or directory created within watched directory<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u521b\u5efa\u5728\u76d1\u63a7\u76ee\u5f55\u4e2d<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"141\">delete<\/p>\n<p><strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td valign=\"top\" width=\"556\">file or directory deleted within watched directory<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u88ab\u5220\u9664\u5728\u76d1\u63a7\u76ee\u5f55\u4e2d<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"141\">delete_self<\/td>\n<td valign=\"top\" width=\"556\">file or directory was deleted<\/p>\n<p>\u6587\u4ef6\u6216\u76ee\u5f55\u88ab\u5220\u9664\uff0c\u76ee\u5f55\u672c\u8eab\u88ab\u5220\u9664<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"141\">unmount<\/td>\n<td valign=\"top\" width=\"556\">file system containing file or directory unmounted<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\" valign=\"top\" width=\"697\">\u4ee5\u4e0a\u7684\u4fe1\u606f\u53ef\u4ee5\u901a\u8fc7 inotifywait &#8211;help\u00a0 \u83b7\u5f97<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1.5.4.1\u00a0\u3010<strong>\u5b9e\u4f8b<\/strong>\u3011inotifywait\u76d1\u63a7\u4e2d\u7684\u4e8b\u4ef6\u6d4b\u8bd5<\/h4>\n<p>1\u3001\u521b\u5efa\u4e8b\u4ef6<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 data]# touch test2.txt\r\n[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \"%d-%m-%y %H:%M\" --format \"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\" -e create\r\n17-10-17 11:19 \/data\/test2.txt \u4e8b\u4ef6\u4fe1\u606f: CREATE<\/pre>\n<\/div>\n<p>2\u3001\u5220\u9664\u4e8b\u4ef6<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 data]# \\rm -f test1.txt\r\n[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \"%d-%m-%y %H:%M\" --format \"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\" -e delete\r\n17-10-17 11:28 \/data\/test1.txt \u4e8b\u4ef6\u4fe1\u606f: DELETE<\/pre>\n<\/div>\n<p>3\u3001\u4fee\u6539\u4e8b\u4ef6<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 data]# echo \"132\" &gt; test.txt\r\n[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \"%d-%m-%y %H:%M\" --format \"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\" -e close_write\r\n17-10-17 11:30 \/data\/test.txt \u4e8b\u4ef6\u4fe1\u606f: CLOSE_WRITE,CLOSE<\/pre>\n<\/div>\n<p>4\u3001\u79fb\u52a8\u4e8b\u4ef6 moved_to<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 data]# mv \/etc\/hosts .\r\n[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \"%d-%m-%y %H:%M\" --format \"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\" -e moved_to\r\n17-10-17 11:33 \/data\/hosts \u4e8b\u4ef6\u4fe1\u606f: MOVED_TO<\/pre>\n<\/div>\n<p>\u79fb\u52a8\u4e8b\u4ef6 moved_from<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 data]# mv .\/hosts  \/tmp\/\r\n[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \"%d-%m-%y %H:%M\" --format \"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\" -e moved_from\r\n17-10-17 11:34 \/data\/hosts \u4e8b\u4ef6\u4fe1\u606f: MOVED_FROM<\/pre>\n<\/div>\n<h4>1.5.5 inotifywait \u53c2\u6570 &#8211;format &lt;fmt&gt;\u683c\u5f0f\u5b9a\u4e49\u53c2\u6570<\/h4>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"179\">\n<p align=\"center\"><strong>\u547d\u4ee4\u53c2\u6570<\/strong><\/p>\n<\/td>\n<td width=\"518\">\n<p align=\"center\"><strong>\u53c2\u6570\u8bf4\u660e<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"179\">%w<strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"518\">\u4e8b\u4ef6\u51fa\u73b0\u65f6\uff0c\u76d1\u63a7\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u540d\u79f0\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td width=\"179\">%f<strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"518\">\u4e8b\u4ef6\u51fa\u73b0\u65f6\uff0c\u5c06\u663e\u793a\u76d1\u63a7\u76ee\u5f55\u4e0b\u89e6\u53d1\u4e8b\u4ef6\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4fe1\u606f\uff0c\u5426\u5219\u4e3a\u7a7a<\/td>\n<\/tr>\n<tr>\n<td width=\"179\">%e<strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"518\">\u663e\u793a\u53d1\u751f\u7684\u4e8b\u4ef6\u4fe1\u606f\uff0c\u4e0d\u540c\u7684\u4e8b\u4ef6\u4fe1\u606f\u7528\u9017\u53f7\u8fdb\u884c\u5206\u9694<\/td>\n<\/tr>\n<tr>\n<td width=\"179\">%Xe<\/td>\n<td width=\"518\">\u663e\u793a\u53d1\u751f\u7684\u4e8b\u4ef6\u4fe1\u606f\uff0c\u4e0d\u540c\u7684\u4e8b\u4ef6\u4fe1\u606f\u6709x\u8fdb\u884c\u5206\u9694\uff0c\u53ef\u4ee5\u4fee\u6539X\u4e3a\u6307\u5b9a\u5206\u9694\u7b26<\/td>\n<\/tr>\n<tr>\n<td width=\"179\">%T<strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"518\">\u8f93\u51fa\u65f6\u95f4\u683c\u5f0f\u4e2d\u5b9a\u4e49\u7684\u65f6\u95f4\u683c\u5f0f\u4fe1\u606f\uff0c\u901a\u8fc7 &#8211;timefmt option \u8bed\u6cd5\u683c\u5f0f\u6307\u5b9a\u65f6\u95f4\u4fe1\u606f<\/p>\n<p>\u8fd9\u4e2a\u683c\u5f0f\u662f\u901a\u8fc7strftime\u51fd\u6570\u8fdb\u884c\u5339\u914d\u65f6\u95f4\u683c\u5f0f\u4fe1\u606f\u7684<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\" valign=\"top\" width=\"697\"><strong>\u4ee5\u4e0a\u7684\u4fe1\u606f\u53ef\u4ee5\u901a\u8fc7 inotifywait &#8211;help\u00a0 <\/strong><strong>\u83b7\u5f97<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1.5.6 inotifywait \u53c2\u6570&#8211;timefmt &lt;fmt&gt;\u65f6\u95f4\u683c\u5f0f\u53c2\u6570<\/h4>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"141\">\n<p align=\"center\"><strong>\u547d\u4ee4\u53c2\u6570<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"556\">\n<p align=\"center\"><strong>\u53c2\u6570\u8bf4\u660e<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">%d<strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"556\">The day of the month as a decimal number(range 01 to 31)<\/p>\n<p>\u6bcf\u6708\u7684\u7b2c\u51e0\u5929\uff0c\u663e\u793a\u500d\u606f\u4e3a\u5341\u8fdb\u5236\u6570\uff08\u8303\u56f4\u662f 01-31 )<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">%m<strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"556\">The month as a decimal number (range 01 to 12).<\/p>\n<p>\u663e\u793a\u6708\u4efd\uff0c\u663e\u793a\u4fe1\u606f\u4e3a\u5341\u8fdb\u5236\uff08\u8303\u56f4 01-12 )<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">%M<\/td>\n<td width=\"556\">The minute as a decimal number (range 00 to 59).<\/p>\n<p>\u663e\u793a\u5206\u949f\uff0c\u663e\u793a\u4fe1\u606f\u4e3a\u5341\u8fdb\u5236\uff08\u8303\u56f4 00-59 )<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">%y<strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\"556\">The year as a decimal number without a century (range 00 to 99).<\/p>\n<p>\u5e74\u4efd\u4fe1\u606f\uff0c\u663e\u793a\u4fe1\u606f\u4e3a\u5341\u8fdb\u5236\uff0c\u5e76\u4e14\u6ca1\u6709\u4e16\u7eaa\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">%Y<\/td>\n<td width=\"556\">The year as a decimal number including the century.<\/p>\n<p>\u5e74\u4efd\u4fe1\u606f\uff0c\u663e\u793a\u4fe1\u606f\u4e3a\u5341\u8fdb\u5236\uff0c\u5e76\u4e14\u5305\u542b\u4e16\u7eaa\u4fe1\u606f<\/td>\n<\/tr>\n<tr>\n<td width=\"141\">%H<\/td>\n<td width=\"556\">The hour as a decimal number using a 24-hour clock (range 00 to 23).<\/p>\n<p>\u5c0f\u65f6\u4fe1\u606f\uff0c\u663e\u793a\u4fe1\u606f\u4e3a\u5341\u8fdb\u5236\uff0c\u4f7f\u7528 24\u5c0f\u65f6\u5236\uff08\u8303\u56f4 00-23 )<\/td>\n<\/tr>\n<tr>\n<td colspan=\"2\" valign=\"top\" width=\"697\"><strong>\u8bf4\u660e\uff1a\u4ee5\u4e0a\u4fe1\u606f\u53ef\u4ee5\u901a\u8fc7 man strftime<\/strong><strong>\u4fe1\u606f\u83b7\u53d6<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1.5.6.1\u00a0\u4fee\u6539\u8f93\u51fa\u7684\u65e5\u671f\u683c\u5f0f<\/h4>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \"%d\/%m\/%y %H:%M\" --format \"%T %w%f\"\r\n17\/10\/17 11:12 \/data\/test1.txt<\/pre>\n<\/div>\n<h4>1.5.7 -e[\u53c2\u6570] \u91cd\u8981\u76d1\u63a7\u4e8b\u4ef6\u53c2\u6570\u6c47\u603b\u8868\uff1a<\/h4>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"132\"><strong>\u91cd\u8981\u4e8b\u4ef6<\/strong><\/td>\n<td width=\"161\"><strong>\u5305\u542b\u4e8b\u4ef6<\/strong><\/td>\n<td width=\"404\"><strong>\u5907\u6ce8\u8bf4\u660e<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"132\"><strong>close<\/strong><\/td>\n<td width=\"161\">close_write<\/p>\n<p>close_nowrite<\/td>\n<td width=\"404\">\u6587\u4ef6\u6216\u76ee\u5f55\u5173\u95ed\uff0c\u4e0d\u7ba1\u8bfb\u6216\u662f\u5199\u6a21\u5f0f<\/p>\n<p>\u5373\u5305\u542b\u5199\u5173\u95ed\u4e0e\u8bfb\u5173\u95ed<\/td>\n<\/tr>\n<tr>\n<td width=\"132\"><strong>close_write<\/strong><\/td>\n<td width=\"161\">create<\/td>\n<td width=\"404\">\u5305\u542b\u6587\u4ef6\u521b\u5efa\u4e8b\u4ef6\uff0c\u4f46\u4e0d\u5305\u542b\u76ee\u5f55\u521b\u5efa\u4e8b\u4ef6<\/td>\n<\/tr>\n<tr>\n<td width=\"132\"><strong>move<\/strong><\/td>\n<td width=\"161\">moved_to<\/p>\n<p>moved_from<\/td>\n<td width=\"404\">\u6587\u4ef6\u6216\u76ee\u5f55\u4e0d\u7ba1\u79fb\u52a8\u5230\u6216\u662f\u79fb\u52a8\u51fa\u76d1\u63a7\u76ee\u5f55\u90fd\u89e6\u53d1\u4e8b\u4ef6<\/p>\n<p>\u5373\u5305\u542b\u4fe1\u606f\u79fb\u5165\u6216\u79fb\u51fa\u76d1\u63a7\u76ee\u5f55\u4e8b\u4ef6<\/td>\n<\/tr>\n<tr>\n<td colspan=\"3\" width=\"697\">\u91cd\u8981\u53c2\u6570\u6c47\u603b\uff1a\u6839\u636e\u4ee5\u4e0a\u8bf4\u660e\uff0c\u5728\u5b9e\u9645\u4f7f\u7528\u65f6\uff0c\u53ea\u8981\u76d1\u63a7\u4ee5\u4e0b\u4e8b\u4ef6\u5373\u53ef<\/p>\n<p>create \u521b\u5efa\u3001 delete \u5220\u9664\u3001 movedjto \u79fb\u5165\u3001 close_write \u4fee \u6539<\/p>\n<p>inotifywait -mrq \/data &#8211;format &#8220;%w%f&#8221;\u00a0 -e create,delete,moved_to,close_write<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>1.6 \u5bf9inotifywait\u547d\u4ee4\u7684\u6d4b\u8bd5<\/h3>\n<p>\u5bf9inotifywait\u547d\u4ee4\u6d4b\u8bd5\u7684\u8bf4\u660e\uff1a<\/p>\n<p>\u9700\u8981\u6253\u5f00\u4e24\u4e2a\u8fde\u63a5\u7a97\u53e3<\/p>\n<div>\n<p><strong>1<\/strong><strong>\u7a97\u53e3<\/strong>\u8fd0\u884cinotifywait<\/p>\n<p><strong>2<\/strong><strong>\u7a97\u53e3<\/strong>\u5bf9\u6587\u4ef6\u5939\u8fdb\u884c\u64cd\u4f5c\uff0c\u53ef\u5728\u4e00\u7a97\u53e3\u4e2d\u67e5\u770b\u51fainotifywait\u7684\u76d1\u63a7\u8bb0\u5f55<\/p>\n<\/div>\n<h4>1.6.1 \u3001\u521b\u5efa\u6587\u4ef6\u7684\u903b\u8f91\u2193<\/h4>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 ~]# inotifywait \/data\r\nSetting up watches.\r\nWatches established.\r\n\/data\/ CREATE test1.txt\r\n\/data\/ OPEN test1.txt\r\n\/data\/ ATTRIB test1.txt\r\n\/data\/ CLOSE_WRITE,CLOSE test1.txt\r\n\u521b\u5efa\u6587\u4ef6\uff0cinotifywait\u663e\u793a\u521b\u5efa\u6587\u4ef6\u7684\u8fc7\u7a0b\u2191\r\n[root@nfs01 data]# touch test1.txt<\/pre>\n<\/div>\n<h4>1.6.2 \u521b\u5efa\u76ee\u5f55\u903b\u8f91\u2193<\/h4>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 data]# mkdir testdir\r\n[root@nfs01 ~]#\r\n\/data\/ CREATE,ISDIR testdir<\/pre>\n<\/div>\n<h4>1.6.3 \u76d1\u63a7\u5b50\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u2193<\/h4>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 data]# touch  testdir\/test01.txt\r\n[root@nfs01 ~]# inotifywait -mrq  \/data\r\n\/data\/testdir\/ OPEN test01.txt\r\n\/data\/testdir\/ ATTRIB test01.txt\r\n\/data\/testdir\/ CLOSE_WRITE,CLOSE test01.txt<\/pre>\n<\/div>\n<h4>1.6.4 sed\u547d\u4ee4\u4fee\u6539\u903b\u8f91<\/h4>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 data]# sed 's#132#123#g' test.txt -i\r\n \r\n[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \"%d-%m-%y %H:%M\" --format \"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\" -e moved_from\r\n \/data\/test.txt \u4e8b\u4ef6\u4fe1\u606f: OPEN\r\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: CREATE\r\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: OPEN\r\n \/data\/test.txt \u4e8b\u4ef6\u4fe1\u606f: ACCESS\r\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: MODIFY\r\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: ATTRIB\r\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: ATTRIB\r\n \/data\/test.txt \u4e8b\u4ef6\u4fe1\u606f: CLOSE_NOWRITE,CLOSE\r\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: CLOSE_WRITE,CLOSE\r\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: MOVED_FROM\r\n \/data\/test.txt \u4e8b\u4ef6\u4fe1\u606f: MOVED_TO<\/pre>\n<\/div>\n<p><strong>sed<\/strong><strong>\u547d\u4ee4\u66ff\u6362\u903b\u8f91 <\/strong><strong>\uff1a<\/strong><\/p>\n<p>01. \u521b\u5efa\u4e34\u65f6\u6587\u4ef6<\/p>\n<p>02. \u5c06\u539f\u6587\u4ef6\u5185\u5bb9\u653e\u7f6e\u5230\u4e34\u65f6\u6587\u4ef6\u4e2d\uff0c\u4fee\u6539\u66ff\u6362\u4e34\u65f6\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\uff0c\u539f\u6709\u6587\u4ef6\u4e0d\u505a\u6539\u52a8<\/p>\n<p>03. \u91cd\u547d\u540d\u4e34\u65f6\u6587\u4ef6\uff0c\u8986\u76d6\u539f\u6587\u4ef6<\/p>\n<h4>1.6.5 inotifywait\u76d1\u63a7\u4e2d -e \u7684\u53c2\u6570\u4f7f\u7528<\/h4>\n<div class=\"linuxidc_code\">\n<pre>inotifywait -mrq \/data --timefmt \"%d\/%m\/%y %H:%M\" --format \"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\" -e create<\/pre>\n<\/div>\n<p>\u8bf4\u660e\uff1a\u8868\u793a\u53ea\u76d1\u542ccreate\u4e8b\u4ef6<\/p>\n<div class=\"linuxidc_code\">\n<pre>inotifywait -mrq \/data --timefmt \"%d\/%m\/%y %H:%M\" --format \"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\"<\/pre>\n<\/div>\n<p>\u8bf4\u660e\uff1a\u4e0d\u6307\u5b9a-e\u53c2\u6570\uff0c\u8868\u793a\u76d1\u542c\u6240\u6709\u4e8b\u4ef6<\/p>\n<p>02. \u5220\u9664\u4e8b\u4ef6delete<\/p>\n<div class=\"linuxidc_code\">\n<pre>    # inotifywait -mrq \/data --timefmt \"%F %H:%M\" --format \"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %@e\" -e delete\r\n    2017-10-17 11:28 \/data\/02.txt \u4e8b\u4ef6\u4fe1\u606f: DELETE\r\n    2017-10-17 11:28 \/data\/03.txt \u4e8b\u4ef6\u4fe1\u606f: DELETE\r\n    2017-10-17 11:28 \/data\/04.txt \u4e8b\u4ef6\u4fe1\u606f: DELETE<\/pre>\n<\/div>\n<p>03. \u4fee\u6539\u4e8b\u4ef6close_write<\/p>\n<div class=\"linuxidc_code\">\n<pre>  # inotifywait -mrq \/data --timefmt \"%F %H:%M\" --format \"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %@e\" -e delete,close_write\r\n    2017-10-17 11:30 \/data\/oldgirl.txt \u4e8b\u4ef6\u4fe1\u606f: CLOSE_WRITE@CLOSE\r\n    2017-10-17 11:30 \/data\/.oldgirl.txt.swx \u4e8b\u4ef6\u4fe1\u606f: CLOSE_WRITE@CLOSE\r\n    2017-10-17 11:30 \/data\/.oldgirl.txt.swx \u4e8b\u4ef6\u4fe1\u606f: DELETE\r\n    2017-10-17 11:30 \/data\/.oldgirl.txt.swp \u4e8b\u4ef6\u4fe1\u606f: CLOSE_WRITE@CLOSE\r\n    2017-10-17 11:30 \/data\/.oldgirl.txt.swp \u4e8b\u4ef6\u4fe1\u606f: DELETE\r\n    2017-10-17 11:30 \/data\/.oldgirl.txt.swp \u4e8b\u4ef6\u4fe1\u606f: CLOSE_WRITE@CLOSE\r\n    2017-10-17 11:30 \/data\/.oldgirl.txt.swp \u4e8b\u4ef6\u4fe1\u606f: DELETE<\/pre>\n<\/div>\n<p>04. \u79fb\u52a8\u4e8b\u4ef6moved_to<\/p>\n<div class=\"linuxidc_code\">\n<pre>    inotifywait -mrq \/data --timefmt \"%F %H:%M\" --format \"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %@e\" -e delete,close_write,moved_to\r\n    2017-10-17 11:34 \/data\/hosts \u4e8b\u4ef6\u4fe1\u606f: MOVED_TO<\/pre>\n<\/div>\n<h3>1.7 \u5b9e\u65f6\u540c\u6b65\u547d\u4ee4\u53c2\u6570\u793a\u610f\u56fe<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.linuxidc.com\/upload\/2017_11\/171124120724231.png\" alt=\"\" width=\"706\" vspace=\"5\" \/><\/p>\n<h2>\u7b2c2\u7ae0 inotify+rsync\u5b9e\u65f6\u540c\u6b65\u670d\u52a1\u90e8\u7f72<\/h2>\n<h3>2.1 \u7b2c\u4e00\u4e2a\u91cc\u7a0b\u7891\uff1a\u90e8\u7f72rsync\u670d\u52a1<\/h3>\n<h4>2.1.1 rsync\u670d\u52a1\u7aef\u90e8\u7f72<\/h4>\n<p>1)\u8f6f\u4ef6\u662f\u5426\u5b58\u5728<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@backup ~]# rpm -qa |grep rsync\r\nrsync-3.0.6-12.el6.x86_64<\/pre>\n<\/div>\n<div>\n<p>\u9700\u6c42\uff1a\u67e5\u8be2\u5230\u67d0\u4e2a\u547d\u4ee4\u975e\u5e38\u6709\u7528\u3002\u4f46\u662f\u4e0d\u77e5\u9053\u5c5e\u4e8e\u54ea\u4e2a\u8f6f\u4ef6\u5305<\/p>\n<p><span class=\"linuxidc_code\"> yum provides rysnc<\/span><\/p>\n<p>provides\u00a0 Find what package provides the given value<\/p>\n<\/div>\n<p>2)\u8fdb\u884c\u8f6f\u4ef6\u670d\u52a1\u914d\u7f6e<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@backup ~]# vim \/etc\/rsyncd.conf\r\nuid = rsync\r\ngid = rsync\r\nuse chroot = no\r\nmax connections = 200\r\ntimeout = 300\r\npid file = \/var\/run\/rsyncd.pid\r\nlock file = \/var\/run\/rsync.lock\r\nlog file = \/var\/log\/rsyncd.log\r\nignore errors\r\nread only = false\r\nlist = false\r\nhosts allow = 172.16.1.0\/24\r\nauth users = rsync_backup\r\nsecrets file = \/etc\/rsync.password\r\n\r\n[backup]\r\ncomment = \"backup dir by oldboy\"\r\npath = \/backup\r\n\r\n[nfsbackup]\r\ncomment = \"nfsbackup dir by hzs\"\r\npath = \/nfsbackup<\/pre>\n<\/div>\n<p>3)\u521b\u5efarsync\u7ba1\u7406\u7528\u6237<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@backup ~]# useradd -s \/sbin\/nologin -M rsync<\/pre>\n<\/div>\n<p>4)\u521b\u5efa\u6570\u636e\u5907\u4efd\u50a8\u5b58\u76ee\u5f55,\u76ee\u5f55\u4fee\u6539\u5c5e\u4e3b<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@backup ~]# mkdir \/nfsbackup\/\r\n[root@backup ~]# chown -R rsync.rsync \/nfsbackup\/<\/pre>\n<\/div>\n<p>5)\u521b\u5efa\u8ba4\u8bc1\u7528\u6237\u5bc6\u7801\u6587\u4ef6\u5e76\u8fdb\u884c\u6388\u6743600<\/p>\n<div class=\"linuxidc_code\">\n<pre>echo \"rsync_backup:oldboy123\" &gt;&gt;\/etc\/rsync.password\r\nchmod 600 \/etc\/rsync.password<\/pre>\n<\/div>\n<p>6)\u542f\u52a8rsync\u670d\u52a1<\/p>\n<div class=\"linuxidc_code\">\n<pre>rsync --daemon<\/pre>\n<\/div>\n<p>\u81f3\u6b64\u670d\u52a1\u7aef\u914d\u7f6e\u5b8c\u6210<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@backup ~]# ps -ef |grep rsync\r\nroot       2076      1  0 17:05 ?        00:00:00 rsync --daemon\r\nroot       2163   1817  0 17:38 pts\/1    00:00:00 grep --color=auto rsync<\/pre>\n<\/div>\n<h4>2.1.2 rsync\u5ba2\u6237\u7aef\u914d\u7f6e<\/h4>\n<p>1)\u8f6f\u4ef6\u662f\u5426\u5b58\u5728<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@backup ~]# rpm -qa |grep rsync\r\nrsync-3.0.6-12.el6.x86_64<\/pre>\n<\/div>\n<p>2)\u521b\u5efa\u5b89\u5168\u8ba4\u8bc1\u6587\u4ef6\uff0c\u5e76\u8fdb\u884c\u4fee\u6539\u6743\u9650600<\/p>\n<div class=\"linuxidc_code\">\n<pre>echo \"oldboy123\" &gt;&gt;\/etc\/rsync.password\r\nchmod 600 \/etc\/rsync.password<\/pre>\n<\/div>\n<p>3) \u6d4b\u8bd5\u6570\u636e\u4f20\u8f93<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 sersync]# rsync -avz \/data  rsync_backup@172.16.1.41::nfsbackup  --password-file=\/etc\/rsync.password\r\nsending incremental file list\r\ndata\/\r\ndata\/.hzs\r\ndata\/.tar.gz\r\ndata\/.txt<\/pre>\n<\/div>\n<h3>2.2 \u7b2c\u4e8c\u4e2a\u91cc\u7a0b\u7891\uff1a\u90e8\u7f72inotify\u670d\u52a1<\/h3>\n<p>\u9996\u5148\u5148\u786e\u8ba4\u662f\u5426\u6709<strong>epel<\/strong><strong>\u6e90<\/strong>\u7528\u6765\u5b89\u88c5inotify-tools\u8f6f\u4ef6<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 ~]# yum repolist\r\nLoaded plugins: fastestmirror, security\r\nLoading mirror speeds from cached hostfile\r\n * base: mirrors.aliyun.com\r\n * epel: mirrors.aliyun.com\r\n * extras: mirrors.aliyun.com\r\n * updates: mirrors.aliyun.com\r\nrepo id  repo name                                       status\r\nbase     <a title=\"CentOS\" href=\"https:\/\/www.linuxidc.com\/topicnews.aspx?tid=14\" target=\"_blank\">CentOS<\/a>-6 - Base - mirrors.aliyun.com             6,706\r\nepel     Extra Packages for Enterprise Linux 6 - x86_64  12,401\r\nextras   CentOS-6 - Extras - mirrors.aliyun.com              46\r\nupdates  CentOS-6 - Updates - mirrors.aliyun.com            722\r\nrepolist: 19,875<\/pre>\n<\/div>\n<h4>2.2.1 \u5b89\u88c5inotify\u8f6f\u4ef6<\/h4>\n<p>\u4e24\u79cd\u5b89\u88c5\u65b9\u5f0f<\/p>\n<div>\n<p>1\uff09 yum install -y inotify-tools<\/p>\n<p>2\uff09 \u624b\u5de5\u7f16\u8bd1\u5b89\u88c5<\/p>\n<\/div>\n<p>\u6ce8\uff1a<\/p>\n<p>\u624b\u5de5\u7f16\u8bd1\u5b89\u88c5\u65b9\u5f0f\u9700\u8981\u5230github\u4e0a\u8fdb\u884c\u4e0b\u8f7d\u8f6f\u4ef6\u5305<\/p>\n<p>inotify\u8f6f\u4ef6\u7684\u53c2\u8003\u8d44\u6599\u94fe\u63a5\uff1a<\/p>\n<p>https:\/\/github.com\/rvoicilas\/inotify-tools\/wiki<\/p>\n<h4>2.2.2 \u67e5\u770binotify\u5b89\u88c5\u4e0a\u7684\u4e24\u4e2a\u547d\u4ee4(inotifywait,inotifywatch)<\/h4>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 ~]# rpm -ql inotify-tools\r\n\/usr\/bin\/inotifywait      #\u4e3b\u8981\r\n\/usr\/bin\/inotifywatch<\/pre>\n<\/div>\n<h4>2.2.2.1\u00a0inotifywait\u548cinotifywatch\u7684\u4f5c\u7528\uff1a<\/h4>\n<div class=\"linuxidc_code\">\n<pre>\u4e00\u5171\u5b89\u88c5\u4e862\u4e2a\u5de5\u5177\uff08\u547d\u4ee4\uff09\uff0c\u5373inotifywait\u548cinotifywatch\r\ninotifywait : \u5728\u88ab\u76d1\u63a7\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u4e0a\u7b49\u5f85\u7279\u5b9a\u6587\u4ef6\u7cfb\u7edf\u4e8b\u4ef6\uff08open close delete\u7b49\uff09\u53d1\u751f\uff0c\r\n\u6267\u884c\u540e\u5904\u4e8e\u963b\u585e\u72b6\u6001\uff0c\u9002\u5408\u5728shell\u811a\u672c\u4e2d\u4f7f\u7528\r\ninotifywatch :\u6536\u96c6\u88ab\u76d1\u63a7\u7684\u6587\u4ef6\u7cfb\u7edf\u4f7f\u7528\u7684\u7edf\u8ba1\u6570\u636e,\u6307\u6587\u4ef6\u7cfb\u7edf\u4e8b\u4ef6\u53d1\u751f\u7684\u6b21\u6570\u7edf\u8ba1\u3002\r\n\u8bf4\u660e\uff1ayum\u5b89\u88c5\u540e\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\uff0c\u5982\u679c\u7f16\u8bd1\u5b89\u88c5\u9700\u8981\u8fdb\u5165\u5230\u76f8\u5e94\u8f6f\u4ef6\u76ee\u5f55\u7684bin\u76ee\u5f55\u4e0b\u4f7f\u7528\r\n \r\n#\u547d\u4ee4 man\u624b\u518c\u8bf4\u660e\r\n# man inotifywait\r\ninotifywait - wait for changes to files using inotify\r\n\r\n\u4f7f\u7528inotify\u8fdb\u884c\u76d1\u63a7\uff0c\u7b49\u5f85\u4ea7\u751f\u53d8\u5316\u7684\u6587\u4ef6\u4fe1\u606f\r\n# man inotifywatch\r\ninotifywatch - gather filesystem access statistics using inotify\r\n\u4f7f\u7528inotify\u8fdb\u884c\u76d1\u63a7\uff0c\u6536\u96c6\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\u7edf\u8ba1\u4f76\u606f<\/pre>\n<\/div>\n<h3>2.3 \u7b2c\u4e09\u4e2a\u91cc\u7a0b\u7891\uff1a\u7f16\u5199\u811a\u672c\uff0c\u5b9e\u73b0rsync+inotify\u8f6f\u4ef6\u529f\u80fd\u7ed3\u5408<\/h3>\n<h4>2.3.1 rsync\u670d\u52a1\u547d\u4ee4\uff1a<\/h4>\n<div class=\"linuxidc_code\">\n<pre>rsync -avz --delete \/data\/ rsync_backup@172.16.1.41::nfsbackup --password-file=\/etc\/rsync.password<\/pre>\n<\/div>\n<h4>2.3.2 inotify\u670d\u52a1\u547d\u4ee4\uff1a<\/h4>\n<div class=\"linuxidc_code\">\n<pre>inotifywait -mrq \/data -format \"%w%f\"  -e create,delete,move_to,close_write<\/pre>\n<\/div>\n<h4>2.3.3 \u7f16\u5199\u811a\u672c\uff1a<\/h4>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 sersync]# vim \/server\/scripts\/inotify.sh\r\n#!\/bin\/bash\r\ninotifywait -mrq \/data --format \"%w%f\" -e create,delete,moved_to,close_write|\\\r\nwhile read line\r\ndo\r\n        rsync -az --delete \/data\/ rsync_backup@172.16.1.41::nfsbackup --password-\r\nfile=\/etc\/rsync.password\r\ndone<\/pre>\n<\/div>\n<p>\u811a\u672c\u8bf4\u660e\uff1a<\/p>\n<div>\n<p>for\u5faa\u73af\u4f1a\u5b9a\u4e49\u4e00\u4e2a\u6761\u4ef6\uff0c\u5f53\u6761\u4ef6\u4e0d\u6ee1\u8db3\u65f6\u505c\u6b62\u5faa\u73af<\/p>\n<p>while\u5faa\u73af\uff1a\u53ea\u8981\u6761\u4ef6\u6ee1\u8db3\u5c31\u4e00\u76f4\u5faa\u73af\u4e0b\u53bb<\/p>\n<\/div>\n<h4>2.3.4 \u5bf9\u811a\u672c\u8fdb\u884c\u4f18\u5316<\/h4>\n<div class=\"linuxidc_code\">\n<pre>#!\/bin\/bash\r\nPath=\/data\r\nbackup_Server=172.16.1.41\r\n\/usr\/bin\/inotifywait -mrq --format '%w%f' -e create,close_write,delete \/data  | while read line  \r\ndo\r\n    if [ -f $line ];then\r\n        rsync -az $line --delete rsync_backup@$backup_Server::nfsbackup --password-file=\/etc\/rsync.password\r\n    else\r\n        cd $Path &amp;&amp;\\\r\n        rsync -az .\/ --delete rsync_backup@$backup_Server::nfsbackup --password-file=\/etc\/rsync.password\r\n    fi\r\ndone<\/pre>\n<\/div>\n<h3>2.4 \u7b2c\u56db\u4e2a\u91cc\u7a0b\u7891\uff1a\u6d4b\u8bd5\u7f16\u5199\u7684\u811a\u672c<\/h3>\n<h4>2.4.1 \u8ba9\u811a\u672c\u5728\u540e\u53f0\u8fd0\u884c<\/h4>\n<p>\u5728\/data \u76ee\u5f55\u5148\u521b\u5efa6\u4e2a\u6587\u4ef6<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 data]# sh  \/server\/scripts\/inotify.sh &amp;\r\n[root@nfs01 data]# touch {1..6}.txt<\/pre>\n<\/div>\n<p>\u5728backup\u670d\u52a1\u5668\u4e0a\uff0c\u5df2\u7ecf\u65f6\u5019\u540c\u6b65\u8fc7\u53bb\u4e866\u4e2a\u6587\u4ef6\u3002<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@backup ~]# ll \/nfsbackup\/\r\ntotal 8\r\n-rw-r--r-- 1 rsync rsync 0 Oct 17 12:06 1.txt\r\n-rw-r--r-- 1 rsync rsync 0 Oct 17 12:06 2.txt\r\n-rw-r--r-- 1 rsync rsync 0 Oct 17 12:06 3.txt\r\n-rw-r--r-- 1 rsync rsync 0 Oct 17 12:06 4.txt\r\n-rw-r--r-- 1 rsync rsync 0 Oct 17 12:06 5.txt\r\n-rw-r--r-- 1 rsync rsync 0 Oct 17 12:06 6.txt<\/pre>\n<\/div>\n<h3>2.5 \u5229\u7528while\u5faa\u73af\u8bed\u53e5\u7f16\u5199\u7684\u811a\u672c\u505c\u6b62\u65b9\u6cd5\uff08kill\uff09<\/h3>\n<div class=\"linuxidc_code\">\n<pre>01. ctrl+z\u6682\u505c\u7a0b\u5e8f\u8fd0\u884c\uff0ckill -9\u6740\u6b7b\r\n02. \u4e0d\u8981\u6682\u505c\u7a0b\u5e8f\uff0c\u76f4\u63a5\u5229\u7528\u6740\u624b\u4e09\u5251\u5ba2\u8fdb\u884c\u6740\u8fdb\u7a0b<\/pre>\n<\/div>\n<p><strong>\u00a0<\/strong><strong>\u8bf4\u660e\uff1a<\/strong>kill\u4e09\u4e2a\u6740\u624b\u4e0d\u662f\u4e07\u80fd\u7684\uff0c\u5728\u8fdb\u7a0b\u6682\u505c\u65f6\uff0c\u65e0\u6cd5\u6740\u6b7b\uff1b<strong>kill -9 <\/strong><strong>\uff08\u5371\u9669\uff09<\/strong><\/p>\n<h4>2.5.1 \u67e5\u770b\u540e\u53f0\u90fd\u8981\u54ea\u4e9b\u7a0b\u5e8f\u5728\u8fd0\u884c<\/h4>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 data]# jobs\r\n[1]+  Running                 sh \/server\/scripts\/inotify.sh &amp;<\/pre>\n<\/div>\n<h4>2.5.2 fg\u5c06\u540e\u53f0\u7684\u7a0b\u5e8f\u8c03\u5230\u524d\u53f0\u6765<\/h4>\n<div class=\"linuxidc_code\">\n<pre>[root@nfs01 data]# fg 1\r\nsh \/server\/scripts\/inotify.sh<\/pre>\n<\/div>\n<h3>2.6 \u8fdb\u7a0b\u7684\u524d\u53f0\u548c\u540e\u53f0\u8fd0\u884c\u65b9\u6cd5\uff1a<\/h3>\n<div>\n<p>\u00a0 \u00a0 fg \u00a0 \u00a0&#8212; \u524d\u53f0<\/p>\n<p>bg\u00a0 \u00a0 &#8212; \u540e\u53f0<\/p>\n<\/div>\n<h4>2.6.1 \u811a\u672c\u540e\u53f0\u8fd0\u884c\u65b9\u6cd5<\/h4>\n<div class=\"linuxidc_code\">\n<pre>    01. sh inotify.sh &amp;\r\n    02. nohup sh inotify.sh &amp;\r\n    03. screen\u5b9e\u73b0\u811a\u672c\u7a0b\u5e8f\u540e\u53f0\u8fd0\u884c<\/pre>\n<\/div>\n<div>\n<p>sh \/server\/scripts\/inotify.sh &amp;<\/p>\n<\/div>\n<p>nohup<\/p>\n<div class=\"linuxidc_code\">\n<pre>nohup sh inotify.sh &amp;<\/pre>\n<\/div>\n<h3>2.7 screen\u5b9e\u73b0\u811a\u672c\u7a0b\u5e8f\u540e\u53f0\u8fd0\u884c<\/h3>\n<h4>2.7.1 \u7ecf\u8fc7yum\u67e5\u627e\u53d1\u73b0screen\u547d\u4ee4\u5c5e\u4e8escreen\u5305<\/h4>\n<div class=\"linuxidc_code\">\n<pre>[root@test ~]# yum provides screen\r\nLoaded plugins: fastestmirror, security\r\nLoading mirror speeds from cached hostfile\r\n * base: mirrors.aliyun.com\r\n * epel: mirrors.aliyun.com\r\n * extras: mirrors.aliyun.com\r\n * updates: mirrors.aliyun.com\r\nbase                                                      | 3.7 kB     00:00    \r\nepel                                                      | 4.3 kB     00:00    \r\nextras                                                    | 3.4 kB     00:00    \r\nupdates                                                   | 3.4 kB     00:00    \r\nscreen-4.0.3-19.el6.x86_64 : A screen manager that supports multiple logins on\r\n                           : one terminal\r\nRepo        : base\r\nMatched from:<\/pre>\n<\/div>\n<h4>2.7.2 \u5b89\u88c5screen\u8f6f\u4ef6<\/h4>\n<div class=\"linuxidc_code\">\n<pre>[root@test ~]# yum install -y  screen<\/pre>\n<\/div>\n<h4>2.7.3 screen\u547d\u4ee4\u7684\u53c2\u6570<\/h4>\n<p>\u5728shell\u4e2d\u8f93\u5165 screen\u5373\u53ef\u8fdb\u5165screen \u89c6\u56fe<\/p>\n<div class=\"linuxidc_code\">\n<pre>[root@test ~]# screen<\/pre>\n<\/div>\n<p><strong>Screen<\/strong><strong>\u5b9e\u73b0\u540e\u53f0\u8fd0\u884c\u7a0b\u5e8f\u7684\u7b80\u5355\u6b65\u9aa4:<\/strong><\/p>\n<div>\n<p>\u00a0 screen -ls \uff1a\u53ef\u770bscreen\u4f1a\u8bdd<\/p>\n<p>screen -r ID :\u6307\u5b9a\u8fdb\u5165\u54ea\u4e2ascreen\u4f1a\u8bdd<\/p>\n<\/div>\n<p><strong>Screen<\/strong><strong>\u547d\u4ee4\u4e2d\u7528\u5230\u7684\u5feb\u6377\u952e<\/strong><\/p>\n<div>\n<p>\u00a0 Ctrl+a c \uff1a\u521b\u5efa\u7a97\u53e3<\/p>\n<p>Ctrl+a w \uff1a\u7a97\u53e3\u5217\u8868<\/p>\n<p>Ctrl+a n \uff1a\u4e0b\u4e00\u4e2a\u7a97\u53e3<\/p>\n<p>Ctrl+a p \uff1a\u4e0a\u4e00\u4e2a\u7a97\u53e3<\/p>\n<p>Ctrl+a 0-9 \uff1a\u5728\u7b2c0\u4e2a\u7a97\u53e3\u548c\u7b2c9\u4e2a\u7a97\u53e3\u4e4b\u95f4\u5207\u6362<\/p>\n<p>Ctrl+a K(\u5927\u5199) \uff1a\u5173\u95ed\u5f53\u524d\u7a97\u53e3\uff0c\u5e76\u4e14\u5207\u6362\u5230\u4e0b\u4e00\u4e2a\u7a97\u53e3 \uff0c<\/p>\n<p>\uff08\u5f53\u9000\u51fa\u6700\u540e\u4e00\u4e2a\u7a97\u53e3\u65f6\uff0c\u8be5\u7ec8\u7aef\u81ea\u52a8\u7ec8\u6b62\uff0c\u5e76\u4e14\u9000\u56de\u5230\u539f\u59cbshell\u72b6\u6001\uff09<\/p>\n<p>exit \uff1a\u5173\u95ed\u5f53\u524d\u7a97\u53e3\uff0c\u5e76\u4e14\u5207\u6362\u5230\u4e0b\u4e00\u4e2a\u7a97\u53e3<\/p>\n<p>\uff08\u5f53\u9000\u51fa\u6700\u540e\u4e00\u4e2a\u7a97\u53e3\u65f6\uff0c\u8be5\u7ec8\u7aef\u81ea\u52a8\u7ec8\u6b62\uff0c\u5e76\u4e14\u9000\u56de\u5230\u539f\u59cbshell\u72b6\u6001\uff09<\/p>\n<p>Ctrl+a d \uff1a\u9000\u51fa\u5f53\u524d\u7ec8\u7aef\uff0c\u8fd4\u56de\u52a0\u8f7dscreen\u524d\u7684shell\u547d\u4ee4\u72b6\u6001<\/p>\n<p>Ctrl+a &#8221; : \u7a97\u53e3\u5217\u8868\u4e0d\u540c\u4e8ew<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c1\u7ae0 \u6570\u636e\u5b9e\u65f6\u540c\u6b65\u4ecb\u7ecd 1.1 \u4ec0\u4e48\u662f\u5b9e\u65f6\u540c\u6b65\uff1a\u5982\u4f55\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65 A.\u00a0\u8981\u5229\u7528\u76d1\u63a7\u670d\u52a1\uff08inotify\uff09\uff0c\u76d1 &#8230; <a title=\"inotify+rsync\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65\" class=\"read-more\" href=\"https:\/\/cn.hostease.com\/xueyuan\/jishu\/linux\/inotifyrsync%e5%ae%9e%e7%8e%b0%e5%ae%9e%e6%97%b6%e5%90%8c%e6%ad%a5\/\" aria-label=\"\u9605\u8bfb inotify+rsync\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[49],"tags":[94,93],"class_list":["post-2913","post","type-post","status-publish","format-standard","hentry","category-linux","tag-inotify","tag-rsync"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/2913","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/comments?post=2913"}],"version-history":[{"count":1,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/2913\/revisions"}],"predecessor-version":[{"id":2914,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/2913\/revisions\/2914"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/media?parent=2913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/categories?post=2913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/tags?post=2913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}