{"id":5419,"date":"2020-07-31T21:42:10","date_gmt":"2020-07-31T13:42:10","guid":{"rendered":"http:\/\/39.97.231.10\/?p=5419"},"modified":"2020-07-31T21:42:10","modified_gmt":"2020-07-31T13:42:10","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":"http:\/\/www.weijing.co\/?p=5419","title":{"rendered":"inotify+rsync\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65"},"content":{"rendered":"<header class=\\\"entry-header\\\">\n<h1 class=\\\"entry-title\\\"><span style=\\\"font-size: 1.53846rem;\\\">\u7b2c1\u7ae0 \u6570\u636e\u5b9e\u65f6\u540c\u6b65\u4ecb\u7ecd<\/span><\/h1>\n<\/header>\n<div class=\\\"entry-content\\\">\n<div class=\\\"single-content\\\">\n<h2><span id=\\\"11\\\">1.1\u00a0\u4ec0\u4e48\u662f\u5b9e\u65f6\u540c\u6b65\uff1a\u5982\u4f55\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65<\/span><\/h2>\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<br \/>\nB.\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<h2><span id=\\\"12\\\">1.2\u00a0\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65\u7684\u65b9\u6cd5<\/span><\/h2>\n<p>inotify+rsync\u00a0\u65b9\u5f0f\u5b9e\u73b0\u6570\u636e\u540c\u6b65<br \/>\nsersync\u00a0\u65b9\u5f0f\u5b9e\u73b0\u5b9e\u65f6\u6570\u636e\u540c\u6b65<\/p>\n<h3><span id=\\\"121\\\">1.2.1\u00a0\u5b9e\u65f6\u540c\u6b65\u539f\u7406\u4ecb\u7ecd<\/span><\/h3>\n<p><img src=\\\"https:\/\/clsn.io\/wp-content\/themes\/clsn-003\/img\/blank.gif\\\" alt=\\\"inotify+rsync\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65\\\" data-original=\\\"https:\/\/images2017.cnblogs.com\/blog\/1190037\/201802\/1190037-20180208094604529-2106245770.png\\\" \/><\/p>\n<h2><span id=\\\"13_inotifyrsync\\\">1.3 inotify+rsync\u00a0\u65b9\u5f0f\u5b9e\u73b0\u6570\u636e\u540c\u6b65<\/span><\/h2>\n<h3><span id=\\\"131_Inotify\\\">1.3.1 Inotify\u7b80\u4ecb<\/span><\/h3>\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\u00a0Inotify\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\u00a0<strong>inotify-tools<\/strong>\u00a0\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\u63d0\u793a\u4fe1\u606f\uff1a<br \/>\nsersync\u8f6f\u4ef6\u5b9e\u9645\u4e0a\u5c31\u662f\u5728\u00a0inotify\u8f6f\u4ef6\u57fa\u7840\u4e0a\u8fdb\u884c\u5f00\u53d1\u7684\uff0c\u529f\u80fd\u8981\u66f4\u52a0\u5f3a\u5927\u4e9b\u00a0\uff0c\u591a\u4e86\u5b9a\u65f6\u91cd\u4f20\u673a\u5236\uff0c\u8fc7\u6ee4\u673a\u5236\u4e86\u63d0\u4f9b\u63a5\u53e3\u505a\u00a0CDN\uff0c\u652f\u6301\u591a\u7ebf\u7a0b\u6a7e\u4f5c\u3002\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<br \/>\ninotify\u7684\u5b9e\u73b0\u6709\u51e0\u6b3e\u8f6f\u4ef6\uff1a<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>inotify-tools\uff0csersync\uff0clrsyncd<\/pre>\n<\/div>\n<h3><span id=\\\"132_inotifyrsync\\\">1.3.2 inotify+rsync\u4f7f\u7528\u65b9\u5f0f<\/span><\/h3>\n<p>inotify\u00a0\u5bf9\u540c\u6b65\u6570\u636e\u76ee\u5f55\u4fe1\u606f\u7684\u76d1\u63a7<br \/>\nrsync\u00a0\u00a0\u5b8c\u6210\u5bf9\u6570\u636e\u4fe1\u606f\u7684\u5b9e\u65f6\u540c\u6b65<br \/>\n\u5229\u7528\u811a\u672c\u8fdb\u884c\u7ed3\u5408<\/p>\n<h2><span id=\\\"14_inotify\\\">1.4\u00a0\u90e8\u7f72inotify\u8f6f\u4ef6\u7684\u524d\u63d0<\/span><\/h2>\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=\\\"cnblogs_code\\\">\n<pre>[root@backup ~]# ll \/proc\/sys\/fs\/inotify\/\ntotal 0\n-rw-r--r-- 1 root root 0 Oct 17 10:12 max_queued_events\n-rw-r--r-- 1 root root 0 Oct 17 10:12 max_user_instances\n-rw-r--r-- 1 root root 0 Oct 17 10:12 max_user_watches<\/pre>\n<\/div>\n<h3><span id=\\\"141\\\">1.4.1\u00a0\u4e09\u4e2a\u91cd\u8981\u6587\u4ef6\u7684\u8bf4\u660e<\/span><\/h3>\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<h3><span id=\\\"142\\\">1.4.2\u00a0\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<\/span><\/h3>\n<h3><span id=\\\"143\\\">1.4.3\u00a0\u3010\u5b98\u65b9\u8bf4\u660e\u3011\u4e09\u4e2a\u91cd\u8981\u6587\u4ef6<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 ~]# man proc\n\/proc\/sys\/fs\/inotify (since Linux 2.6.13)\n       This   directory   contains    files    max_queued_events,\n       max_user_instances, and max_user_watches, that can be used\n       to limit the amount of kernel memory consumed by the  inotify interface.\nfor further details, see inotify(7).<\/pre>\n<\/div>\n<div>\n\u901a\u8fc7man\u624b\u518c\u7684\u7b2c7\u7ea7\u522b\u4e2d\u67e5\u5230\u00a0inotify\u7684\u9ed8\u8ba4\u6587\u4ef6\u7684\u8be6\u7ec6\u8bf4\u660e\u3002\n<\/div>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 ~]# man 7 inotify\n\/proc\/sys\/fs\/inotify\/max_queued_events\n       The  value  in this file is used when an application calls\n       inotify_init(2) to set an upper limit  on  the  number  of\n       events  that  can  be  queued to the corresponding inotify\n       instance.  Events in excess of this limit are dropped, but\n       an IN_Q_OVERFLOW event is always generated.\n\/proc\/sys\/fs\/inotify\/max_user_instances\n       This  specifies  an  upper  limit on the number of inotify\n       instances that can be created per real user ID.\n\/proc\/sys\/fs\/inotify\/max_user_watches\n       This specifies an upper limit on  the  number  of  watches\n       that can be created per real user ID.<\/pre>\n<\/div>\n<h2><span id=\\\"15_inotify\\\">1.5 inotify\u8f6f\u4ef6\u4ecb\u7ecd\u53ca\u53c2\u6570\u8bf4\u660e<\/span><\/h2>\n<h3><span id=\\\"151\\\">1.5.1\u00a0\u4e24\u79cd\u5b89\u88c5\u65b9\u5f0f<\/span><\/h3>\n<div>\n1\uff09\u00a0yum install -y inotify-tools<br \/>\n2\uff09\u00a0\u624b\u5de5\u7f16\u8bd1\u5b89\u88c5\n<\/div>\n<p>\u6ce8\uff1a\u00a0 \u00a0 YUM\u00a0\u5b89\u88c5\u9700\u8981\u6709epel\u6e90<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>http:\/\/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<br \/>\ninotify\u8f6f\u4ef6\u7684\u53c2\u8003\u8d44\u6599\u94fe\u63a5\uff1a<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>https:\/\/github.com\/rvoicilas\/inotify-tools\/wiki<\/pre>\n<\/div>\n<h3><span id=\\\"152_inotify\\\">1.5.2 inotify\u4e3b\u8981\u5b89\u88c5\u7684\u4e24\u4e2a\u8f6f\u4ef6<\/span><\/h3>\n<div>\n<strong>inotifywait<\/strong><strong>\uff1a\u00a0<\/strong><strong>\uff08\u4e3b\u8981\uff09<\/strong><br \/>\n\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<br \/>\ninotifywatch\uff1a<br \/>\n\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\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<h3><span id=\\\"153_inotifywait\\\">1.5.3 inotifywait\u547d\u4ee4\u53c2\u6570\u8bf4\u660e<\/span><\/h3>\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<br \/>\n<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.<br \/>\n\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<br \/>\n<strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\\\"480\\\">Watch all subdirectories of any directories passed as arguments.<br \/>\n\u9012\u5f52\u76d1\u63a7\u76ee\u5f55\u6570\u636e\u4fe1\u606f\u53d8\u5316<\/td>\n<\/tr>\n<tr>\n<td width=\\\"217\\\">-o, &#8211;outfile<\/td>\n<td width=\\\"480\\\">Print events to\u00a0rather than stdout.<br \/>\n\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.<br \/>\n\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<br \/>\n<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.<br \/>\n\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<\/td>\n<td width=\\\"480\\\">Exclude all events on files matching the extended regular expression\u00a0.<br \/>\n\u6392\u9664\u6587\u4ef6\u6216\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td width=\\\"217\\\">&#8211;excludei<\/td>\n<td width=\\\"480\\\">Like &#8211;exclude but case insensitive.<br \/>\n\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<br \/>\n<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.<br \/>\n\u6307\u5b9a\u65f6\u95f4\u8f93\u51fa\u683c\u5f0f<\/td>\n<\/tr>\n<tr>\n<td width=\\\"217\\\">&#8211;format<br \/>\n<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.<br \/>\n\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><br \/>\n<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.<br \/>\n\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\u00a0inotifywait &#8211;help\u00a0\u00a0\u83b7\u5f97<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><span id=\\\"154_-e_nbsp\\\">1.5.4 -e[\u53c2\u6570] \u00a0\u53ef\u4ee5\u6307\u5b9a\u7684\u4e8b\u4ef6\u7c7b\u578b<\/span><\/h3>\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<br \/>\n\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<br \/>\n\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<br \/>\n\u6587\u4ef6\u6216\u76ee\u5f55\u5c5e\u6027\u6539\u53d8<\/td>\n<\/tr>\n<tr>\n<td width=\\\"141\\\">close_write<br \/>\n<strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td width=\\\"556\\\">file or directory closed, after being opened in writeable mode.<br \/>\n\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.<br \/>\n\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<br \/>\n\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<br \/>\n\u6587\u4ef6\u6216\u76ee\u5f55\u88ab\u6253\u5f00<\/td>\n<\/tr>\n<tr>\n<td width=\\\"141\\\">moved_to<br \/>\n\u62c9<\/td>\n<td width=\\\"556\\\">file or directory moved to watched directory<br \/>\n\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<br \/>\n\u63a8<\/td>\n<td valign=\\\"top\\\" width=\\\"556\\\">file or directory moved from watched directory<br \/>\n\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<br \/>\n<strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td valign=\\\"top\\\" width=\\\"556\\\">file or directory moved to or from watched directory<br \/>\n\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<br \/>\n<strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td valign=\\\"top\\\" width=\\\"556\\\">file or directory created within watched directory<br \/>\n\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<br \/>\n<strong>\uff08\u91cd\u8981\u53c2\u6570\uff09<\/strong><\/td>\n<td valign=\\\"top\\\" width=\\\"556\\\">file or directory deleted within watched directory<br \/>\n\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<br \/>\n\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\u00a0inotifywait &#8211;help\u00a0\u00a0\u83b7\u5f97<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4><span id=\\\"1541nbspinotifywait\\\">1.5.4.1\u00a0\u3010<strong>\u5b9e\u4f8b<\/strong>\u3011inotifywait\u76d1\u63a7\u4e2d\u7684\u4e8b\u4ef6\u6d4b\u8bd5<\/span><\/h4>\n<p>1\u3001\u521b\u5efa\u4e8b\u4ef6<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 data]# touch test2.txt\n[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \\\"%d-%m-%y %H:%M\\\" --format \\\"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\\\" -e create\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=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 data]# \\\\rm -f test1.txt\n[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \\\"%d-%m-%y %H:%M\\\" --format \\\"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\\\" -e delete\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=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 data]# echo \\\"132\\\" &gt; test.txt\n[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \\\"%d-%m-%y %H:%M\\\" --format \\\"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\\\" -e close_write\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\u00a0moved_to<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 data]# mv \/etc\/hosts .\n[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \\\"%d-%m-%y %H:%M\\\" --format \\\"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\\\" -e moved_to\n17-10-17 11:33 \/data\/hosts \u4e8b\u4ef6\u4fe1\u606f: MOVED_TO<\/pre>\n<\/div>\n<p>\u79fb\u52a8\u4e8b\u4ef6\u00a0moved_from<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 data]# mv .\/hosts  \/tmp\/\n[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \\\"%d-%m-%y %H:%M\\\" --format \\\"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\\\" -e moved_from\n17-10-17 11:34 \/data\/hosts \u4e8b\u4ef6\u4fe1\u606f: MOVED_FROM<\/pre>\n<\/div>\n<h3><span id=\\\"155_inotifywait_--format\\\">1.5.5 inotifywait\u00a0\u53c2\u6570\u00a0&#8211;format\u00a0\u683c\u5f0f\u5b9a\u4e49\u53c2\u6570<\/span><\/h3>\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\u00a0&#8211;timefmt option\u00a0\u8bed\u6cd5\u683c\u5f0f\u6307\u5b9a\u65f6\u95f4\u4fe1\u606f<br \/>\n\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\u00a0inotifywait &#8211;help\u00a0\u00a0<\/strong><strong>\u83b7\u5f97<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><span id=\\\"156_inotifywait_--timefmt\\\">1.5.6 inotifywait\u00a0\u53c2\u6570&#8211;timefmt\u00a0\u65f6\u95f4\u683c\u5f0f\u53c2\u6570<\/span><\/h3>\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)<br \/>\n\u6bcf\u6708\u7684\u7b2c\u51e0\u5929\uff0c\u663e\u793a\u500d\u606f\u4e3a\u5341\u8fdb\u5236\u6570\uff08\u8303\u56f4\u662f\u00a001-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).<br \/>\n\u663e\u793a\u6708\u4efd\uff0c\u663e\u793a\u4fe1\u606f\u4e3a\u5341\u8fdb\u5236\uff08\u8303\u56f4\u00a001-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).<br \/>\n\u663e\u793a\u5206\u949f\uff0c\u663e\u793a\u4fe1\u606f\u4e3a\u5341\u8fdb\u5236\uff08\u8303\u56f4\u00a000-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).<br \/>\n\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.<br \/>\n\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).<br \/>\n\u5c0f\u65f6\u4fe1\u606f\uff0c\u663e\u793a\u4fe1\u606f\u4e3a\u5341\u8fdb\u5236\uff0c\u4f7f\u7528\u00a024\u5c0f\u65f6\u5236\uff08\u8303\u56f4\u00a000-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\u00a0man strftime<\/strong><strong>\u4fe1\u606f\u83b7\u53d6<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4><span id=\\\"1561nbsp\\\">1.5.6.1\u00a0\u4fee\u6539\u8f93\u51fa\u7684\u65e5\u671f\u683c\u5f0f<\/span><\/h4>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \\\"%d\/%m\/%y %H:%M\\\" --format \\\"%T %w%f\\\"\n17\/10\/17 11:12 \/data\/test1.txt<\/pre>\n<\/div>\n<h3><span id=\\\"157_-e\\\">1.5.7 -e[\u53c2\u6570]\u00a0\u91cd\u8981\u76d1\u63a7\u4e8b\u4ef6\u53c2\u6570\u6c47\u603b\u8868\uff1a<\/span><\/h3>\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<br \/>\nclose_nowrite<\/td>\n<td width=\\\"404\\\">\u6587\u4ef6\u6216\u76ee\u5f55\u5173\u95ed\uff0c\u4e0d\u7ba1\u8bfb\u6216\u662f\u5199\u6a21\u5f0f<br \/>\n\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<br \/>\nmoved_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<br \/>\n\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<br \/>\ncreate\u00a0\u521b\u5efa\u3001\u00a0delete\u00a0\u5220\u9664\u3001\u00a0movedjto\u00a0\u79fb\u5165\u3001\u00a0close_write\u00a0\u4fee\u00a0\u6539<br \/>\ninotifywait -mrq \/data &#8211;format \\&#8221;%w%f\\&#8221;\u00a0 -e create,delete,moved_to,close_write<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span id=\\\"16_inotifywait\\\">1.6\u00a0\u5bf9inotifywait\u547d\u4ee4\u7684\u6d4b\u8bd5<\/span><\/h2>\n<p>\u5bf9inotifywait\u547d\u4ee4\u6d4b\u8bd5\u7684\u8bf4\u660e\uff1a<br \/>\n\u9700\u8981\u6253\u5f00\u4e24\u4e2a\u8fde\u63a5\u7a97\u53e3<\/p>\n<div>\n<strong>1<\/strong><strong>\u7a97\u53e3<\/strong>\u8fd0\u884cinotifywait<br \/>\n<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\n<\/div>\n<h3><span id=\\\"161_darr\\\">1.6.1\u00a0\u3001\u521b\u5efa\u6587\u4ef6\u7684\u903b\u8f91\u2193<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 ~]# inotifywait \/data\nSetting up watches.\nWatches established.\n\/data\/ CREATE test1.txt\n\/data\/ OPEN test1.txt\n\/data\/ ATTRIB test1.txt\n\/data\/ CLOSE_WRITE,CLOSE test1.txt\n\u521b\u5efa\u6587\u4ef6\uff0cinotifywait\u663e\u793a\u521b\u5efa\u6587\u4ef6\u7684\u8fc7\u7a0b\u2191\n[root@nfs01 data]# touch test1.txt<\/pre>\n<\/div>\n<h3><span id=\\\"162_darr\\\">1.6.2\u00a0\u521b\u5efa\u76ee\u5f55\u903b\u8f91\u2193<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 data]# mkdir testdir\n[root@nfs01 ~]#\n\/data\/ CREATE,ISDIR testdir<\/pre>\n<\/div>\n<h3><span id=\\\"163_darr\\\">1.6.3\u00a0\u76d1\u63a7\u5b50\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u2193<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 data]# touch  testdir\/test01.txt\n[root@nfs01 ~]# inotifywait -mrq  \/data\n\/data\/testdir\/ OPEN test01.txt\n\/data\/testdir\/ ATTRIB test01.txt\n\/data\/testdir\/ CLOSE_WRITE,CLOSE test01.txt<\/pre>\n<\/div>\n<h3><span id=\\\"164_sed\\\">1.6.4\u00a0sed\u547d\u4ee4\u4fee\u6539\u903b\u8f91<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 data]# sed \\'s#132#123#g\\' test.txt -i\n[root@nfs01 ~]# inotifywait -mrq  \/data --timefmt \\\"%d-%m-%y %H:%M\\\" --format \\\"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %e\\\" -e moved_from\n \/data\/test.txt \u4e8b\u4ef6\u4fe1\u606f: OPEN\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: CREATE\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: OPEN\n \/data\/test.txt \u4e8b\u4ef6\u4fe1\u606f: ACCESS\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: MODIFY\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: ATTRIB\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: ATTRIB\n \/data\/test.txt \u4e8b\u4ef6\u4fe1\u606f: CLOSE_NOWRITE,CLOSE\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: CLOSE_WRITE,CLOSE\n \/data\/sedDh5R8v \u4e8b\u4ef6\u4fe1\u606f: MOVED_FROM\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\u00a0<\/strong><strong>\uff1a<\/strong><br \/>\n01.\u00a0\u521b\u5efa\u4e34\u65f6\u6587\u4ef6<br \/>\n02.\u00a0\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<br \/>\n03.\u00a0\u91cd\u547d\u540d\u4e34\u65f6\u6587\u4ef6\uff0c\u8986\u76d6\u539f\u6587\u4ef6<\/p>\n<h3><span id=\\\"165_inotifywait_-e\\\">1.6.5 inotifywait\u76d1\u63a7\u4e2d\u00a0-e\u00a0\u7684\u53c2\u6570\u4f7f\u7528<\/span><\/h3>\n<div class=\\\"cnblogs_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=\\\"cnblogs_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<br \/>\n02.\u00a0\u5220\u9664\u4e8b\u4ef6delete<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>    # inotifywait -mrq \/data --timefmt \\\"%F %H:%M\\\" --format \\\"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %@e\\\" -e delete\n    2017-10-17 11:28 \/data\/02.txt \u4e8b\u4ef6\u4fe1\u606f: DELETE\n    2017-10-17 11:28 \/data\/03.txt \u4e8b\u4ef6\u4fe1\u606f: DELETE\n    2017-10-17 11:28 \/data\/04.txt \u4e8b\u4ef6\u4fe1\u606f: DELETE<\/pre>\n<\/div>\n<p>03.\u00a0\u4fee\u6539\u4e8b\u4ef6close_write<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>  # inotifywait -mrq \/data --timefmt \\\"%F %H:%M\\\" --format \\\"%T %w%f \u4e8b\u4ef6\u4fe1\u606f: %@e\\\" -e delete,close_write\n    2017-10-17 11:30 \/data\/oldgirl.txt \u4e8b\u4ef6\u4fe1\u606f: CLOSE_WRITE@CLOSE\n    2017-10-17 11:30 \/data\/.oldgirl.txt.swx \u4e8b\u4ef6\u4fe1\u606f: CLOSE_WRITE@CLOSE\n    2017-10-17 11:30 \/data\/.oldgirl.txt.swx \u4e8b\u4ef6\u4fe1\u606f: DELETE\n    2017-10-17 11:30 \/data\/.oldgirl.txt.swp \u4e8b\u4ef6\u4fe1\u606f: CLOSE_WRITE@CLOSE\n    2017-10-17 11:30 \/data\/.oldgirl.txt.swp \u4e8b\u4ef6\u4fe1\u606f: DELETE\n    2017-10-17 11:30 \/data\/.oldgirl.txt.swp \u4e8b\u4ef6\u4fe1\u606f: CLOSE_WRITE@CLOSE\n    2017-10-17 11:30 \/data\/.oldgirl.txt.swp \u4e8b\u4ef6\u4fe1\u606f: DELETE<\/pre>\n<\/div>\n<p>04.\u00a0\u79fb\u52a8\u4e8b\u4ef6moved_to<\/p>\n<div class=\\\"cnblogs_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\n    2017-10-17 11:34 \/data\/hosts \u4e8b\u4ef6\u4fe1\u606f: MOVED_TO<\/pre>\n<\/div>\n<h2><span id=\\\"17\\\">1.7\u00a0\u5b9e\u65f6\u540c\u6b65\u547d\u4ee4\u53c2\u6570\u793a\u610f\u56fe<\/span><\/h2>\n<p><img src=\\\"https:\/\/clsn.io\/wp-content\/themes\/clsn-003\/img\/blank.gif\\\" alt=\\\"inotify+rsync\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65\\\" data-original=\\\"https:\/\/images2017.cnblogs.com\/blog\/1190037\/201710\/1190037-20171022092343990-1382877860.png\\\" \/><\/p>\n<h1><span id=\\\"2_inotifyrsync\\\">\u7b2c2\u7ae0 inotify+rsync\u5b9e\u65f6\u540c\u6b65\u670d\u52a1\u90e8\u7f72<\/span><\/h1>\n<h2><span id=\\\"21_rsync\\\">2.1\u00a0\u7b2c\u4e00\u4e2a\u91cc\u7a0b\u7891\uff1a\u90e8\u7f72rsync\u670d\u52a1<\/span><\/h2>\n<h3><span id=\\\"211_rsync\\\">2.1.1 rsync\u670d\u52a1\u7aef\u90e8\u7f72<\/span><\/h3>\n<p>1)\u8f6f\u4ef6\u662f\u5426\u5b58\u5728<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@backup ~]# rpm -qa |grep rsync\nrsync-3.0.6-12.el6.x86_64<\/pre>\n<\/div>\n<div>\n\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<br \/>\n<span class=\\\"cnblogs_code\\\">\u00a0yum provides rysnc<\/span><br \/>\nprovides\u00a0\u00a0 Find what package provides the given value\n<\/div>\n<p>2)\u8fdb\u884c\u8f6f\u4ef6\u670d\u52a1\u914d\u7f6e<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@backup ~]# vim \/etc\/rsyncd.conf\nuid = rsync\ngid = rsync\nuse chroot = no\nmax connections = 200\ntimeout = 300\npid file = \/var\/run\/rsyncd.pid\nlock file = \/var\/run\/rsync.lock\nlog file = \/var\/log\/rsyncd.log\nignore errors\nread only = false\nlist = false\nhosts allow = 172.16.1.0\/24\nauth users = rsync_backup\nsecrets file = \/etc\/rsync.password\n[backup]\ncomment = \\\"backup dir by oldboy\\\"\npath = \/backup\n[nfsbackup]\ncomment = \\\"nfsbackup dir by hzs\\\"\npath = \/nfsbackup<\/pre>\n<\/div>\n<p>3)\u521b\u5efarsync\u7ba1\u7406\u7528\u6237<\/p>\n<div class=\\\"cnblogs_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=\\\"cnblogs_code\\\">\n<pre>[root@backup ~]# mkdir \/nfsbackup\/\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=\\\"cnblogs_code\\\">\n<pre>echo \\\"rsync_backup:oldboy123\\\" &gt;&gt;\/etc\/rsync.password\nchmod 600 \/etc\/rsync.password<\/pre>\n<\/div>\n<p>6)\u542f\u52a8rsync\u670d\u52a1<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>rsync --daemon<\/pre>\n<\/div>\n<p>\u81f3\u6b64\u670d\u52a1\u7aef\u914d\u7f6e\u5b8c\u6210<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@backup ~]# ps -ef |grep rsync\nroot       2076      1  0 17:05 ?        00:00:00 rsync --daemon\nroot       2163   1817  0 17:38 pts\/1    00:00:00 grep --color=auto rsync<\/pre>\n<\/div>\n<h3><span id=\\\"212_rsync\\\">2.1.2 rsync\u5ba2\u6237\u7aef\u914d\u7f6e<\/span><\/h3>\n<p>1)\u8f6f\u4ef6\u662f\u5426\u5b58\u5728<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@backup ~]# rpm -qa |grep rsync\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=\\\"cnblogs_code\\\">\n<pre>echo \\\"oldboy123\\\" &gt;&gt;\/etc\/rsync.password\nchmod 600 \/etc\/rsync.password<\/pre>\n<\/div>\n<p>3)\u00a0\u6d4b\u8bd5\u6570\u636e\u4f20\u8f93<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 sersync]# rsync -avz \/data  rsync_backup@172.16.1.41::nfsbackup  --password-file=\/etc\/rsync.password\nsending incremental file list\ndata\/\ndata\/.hzs\ndata\/.tar.gz\ndata\/.txt<\/pre>\n<\/div>\n<h2><span id=\\\"22_inotify\\\">2.2\u00a0\u7b2c\u4e8c\u4e2a\u91cc\u7a0b\u7891\uff1a\u90e8\u7f72inotify\u670d\u52a1<\/span><\/h2>\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=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 ~]# yum repolist\nLoaded plugins: fastestmirror, security\nLoading mirror speeds from cached hostfile\n * base: mirrors.aliyun.com\n * epel: mirrors.aliyun.com\n * extras: mirrors.aliyun.com\n * updates: mirrors.aliyun.com\nrepo id  repo name                                       status\nbase     CentOS-6 - Base - mirrors.aliyun.com             6,706\nepel     Extra Packages for Enterprise Linux 6 - x86_64  12,401\nextras   CentOS-6 - Extras - mirrors.aliyun.com              46\nupdates  CentOS-6 - Updates - mirrors.aliyun.com            722\nrepolist: 19,875<\/pre>\n<\/div>\n<h3><span id=\\\"221_inotify\\\">2.2.1\u00a0\u5b89\u88c5inotify\u8f6f\u4ef6<\/span><\/h3>\n<p>\u4e24\u79cd\u5b89\u88c5\u65b9\u5f0f<\/p>\n<div>\n1\uff09\u00a0yum install -y inotify-tools<br \/>\n2\uff09\u00a0\u624b\u5de5\u7f16\u8bd1\u5b89\u88c5\n<\/div>\n<p>\u6ce8\uff1a<br \/>\n\u624b\u5de5\u7f16\u8bd1\u5b89\u88c5\u65b9\u5f0f\u9700\u8981\u5230github\u4e0a\u8fdb\u884c\u4e0b\u8f7d\u8f6f\u4ef6\u5305<br \/>\ninotify\u8f6f\u4ef6\u7684\u53c2\u8003\u8d44\u6599\u94fe\u63a5\uff1a<br \/>\nhttps:\/\/github.com\/rvoicilas\/inotify-tools\/wiki<\/p>\n<h3><span id=\\\"222_inotifyinotifywaitinotifywatch\\\">2.2.2\u00a0\u67e5\u770binotify\u5b89\u88c5\u4e0a\u7684\u4e24\u4e2a\u547d\u4ee4(inotifywait,inotifywatch)<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 ~]# rpm -ql inotify-tools\n\/usr\/bin\/inotifywait      #\u4e3b\u8981\n\/usr\/bin\/inotifywatch<\/pre>\n<\/div>\n<h4><span id=\\\"2221nbspinotifywaitinotifywatch\\\">2.2.2.1\u00a0inotifywait\u548cinotifywatch\u7684\u4f5c\u7528\uff1a<\/span><\/h4>\n<div class=\\\"cnblogs_code\\\">\n<pre>\u4e00\u5171\u5b89\u88c5\u4e862\u4e2a\u5de5\u5177\uff08\u547d\u4ee4\uff09\uff0c\u5373inotifywait\u548cinotifywatch\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\n\u6267\u884c\u540e\u5904\u4e8e\u963b\u585e\u72b6\u6001\uff0c\u9002\u5408\u5728shell\u811a\u672c\u4e2d\u4f7f\u7528\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\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\n#\u547d\u4ee4 man\u624b\u518c\u8bf4\u660e\n# man inotifywait\ninotifywait - wait for changes to files using inotify\n\u4f7f\u7528inotify\u8fdb\u884c\u76d1\u63a7\uff0c\u7b49\u5f85\u4ea7\u751f\u53d8\u5316\u7684\u6587\u4ef6\u4fe1\u606f\n# man inotifywatch\ninotifywatch - gather filesystem access statistics using inotify\n\u4f7f\u7528inotify\u8fdb\u884c\u76d1\u63a7\uff0c\u6536\u96c6\u6587\u4ef6\u7cfb\u7edf\u8bbf\u95ee\u7edf\u8ba1\u4f76\u606f<\/pre>\n<\/div>\n<h2><span id=\\\"23_rsyncinotify\\\">2.3\u00a0\u7b2c\u4e09\u4e2a\u91cc\u7a0b\u7891\uff1a\u7f16\u5199\u811a\u672c\uff0c\u5b9e\u73b0rsync+inotify\u8f6f\u4ef6\u529f\u80fd\u7ed3\u5408<\/span><\/h2>\n<h3><span id=\\\"231_rsync\\\">2.3.1 rsync\u670d\u52a1\u547d\u4ee4\uff1a<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>rsync -avz --delete \/data\/ rsync_backup@172.16.1.41::nfsbackup --password-file=\/etc\/rsync.password<\/pre>\n<\/div>\n<h3><span id=\\\"232_inotify\\\">2.3.2 inotify\u670d\u52a1\u547d\u4ee4\uff1a<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>inotifywait -mrq \/data -format \\\"%w%f\\\"  -e create,delete,move_to,close_write<\/pre>\n<\/div>\n<h3><span id=\\\"233\\\">2.3.3\u00a0\u7f16\u5199\u811a\u672c\uff1a<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 sersync]# vim \/server\/scripts\/inotify.sh\n#!\/bin\/bash\ninotifywait -mrq \/data --format \\\"%w%f\\\" -e create,delete,moved_to,close_write|\\\\\nwhile read line\ndo\n        rsync -az --delete \/data\/ rsync_backup@172.16.1.41::nfsbackup --password-\nfile=\/etc\/rsync.password\ndone<\/pre>\n<\/div>\n<p>\u811a\u672c\u8bf4\u660e\uff1a<\/p>\n<div>\nfor\u5faa\u73af\u4f1a\u5b9a\u4e49\u4e00\u4e2a\u6761\u4ef6\uff0c\u5f53\u6761\u4ef6\u4e0d\u6ee1\u8db3\u65f6\u505c\u6b62\u5faa\u73af<br \/>\nwhile\u5faa\u73af\uff1a\u53ea\u8981\u6761\u4ef6\u6ee1\u8db3\u5c31\u4e00\u76f4\u5faa\u73af\u4e0b\u53bb\n<\/div>\n<h3><span id=\\\"234\\\">2.3.4\u00a0\u5bf9\u811a\u672c\u8fdb\u884c\u4f18\u5316<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>#!\/bin\/bash\nPath=\/data\nbackup_Server=172.16.1.41\n\/usr\/bin\/inotifywait -mrq --format \\'%w%f\\' -e create,close_write,delete \/data  | while read line\ndo\n    if [ -f $line ];then\n        rsync -az $line --delete rsync_backup@$backup_Server::nfsbackup --password-file=\/etc\/rsync.password\n    else\n        cd $Path &amp;&amp;\\\\\n        rsync -az .\/ --delete rsync_backup@$backup_Server::nfsbackup --password-file=\/etc\/rsync.password\n    fi\ndone<\/pre>\n<\/div>\n<h2><span id=\\\"24\\\">2.4\u00a0\u7b2c\u56db\u4e2a\u91cc\u7a0b\u7891\uff1a\u6d4b\u8bd5\u7f16\u5199\u7684\u811a\u672c<\/span><\/h2>\n<h3><span id=\\\"241\\\">2.4.1\u00a0\u8ba9\u811a\u672c\u5728\u540e\u53f0\u8fd0\u884c<\/span><\/h3>\n<p>\u5728\/data\u00a0\u76ee\u5f55\u5148\u521b\u5efa6\u4e2a\u6587\u4ef6<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 data]# sh  \/server\/scripts\/inotify.sh &amp;\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=\\\"cnblogs_code\\\">\n<pre>[root@backup ~]# ll \/nfsbackup\/\ntotal 8\n-rw-r--r-- 1 rsync rsync 0 Oct 17 12:06 1.txt\n-rw-r--r-- 1 rsync rsync 0 Oct 17 12:06 2.txt\n-rw-r--r-- 1 rsync rsync 0 Oct 17 12:06 3.txt\n-rw-r--r-- 1 rsync rsync 0 Oct 17 12:06 4.txt\n-rw-r--r-- 1 rsync rsync 0 Oct 17 12:06 5.txt\n-rw-r--r-- 1 rsync rsync 0 Oct 17 12:06 6.txt<\/pre>\n<\/div>\n<h2><span id=\\\"25_whilekill\\\">2.5\u00a0\u5229\u7528while\u5faa\u73af\u8bed\u53e5\u7f16\u5199\u7684\u811a\u672c\u505c\u6b62\u65b9\u6cd5\uff08kill\uff09<\/span><\/h2>\n<div class=\\\"cnblogs_code\\\">\n<pre>01. ctrl+z\u6682\u505c\u7a0b\u5e8f\u8fd0\u884c\uff0ckill -9\u6740\u6b7b\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\u00a0<\/strong><strong>\uff08\u5371\u9669\uff09<\/strong><\/p>\n<h3><span id=\\\"251\\\">2.5.1\u00a0\u67e5\u770b\u540e\u53f0\u90fd\u8981\u54ea\u4e9b\u7a0b\u5e8f\u5728\u8fd0\u884c<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 data]# jobs\n[1]+  Running                 sh \/server\/scripts\/inotify.sh &amp;<\/pre>\n<\/div>\n<h3><span id=\\\"252_fg\\\">2.5.2 fg\u5c06\u540e\u53f0\u7684\u7a0b\u5e8f\u8c03\u5230\u524d\u53f0\u6765<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@nfs01 data]# fg 1\nsh \/server\/scripts\/inotify.sh<\/pre>\n<\/div>\n<h2><span id=\\\"26\\\">2.6\u00a0\u8fdb\u7a0b\u7684\u524d\u53f0\u548c\u540e\u53f0\u8fd0\u884c\u65b9\u6cd5\uff1a<\/span><\/h2>\n<div>\n\u00a0\u00a0\u00a0 fg \u00a0\u00a0\u00a0&#8212;\u00a0\u524d\u53f0<br \/>\nbg\u00a0\u00a0\u00a0 &#8212;\u00a0\u540e\u53f0\n<\/div>\n<h3><span id=\\\"261\\\">2.6.1\u00a0\u811a\u672c\u540e\u53f0\u8fd0\u884c\u65b9\u6cd5<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>    01. sh inotify.sh &amp;\n    02. nohup sh inotify.sh &amp;\n    03. screen\u5b9e\u73b0\u811a\u672c\u7a0b\u5e8f\u540e\u53f0\u8fd0\u884c<\/pre>\n<\/div>\n<div>\nsh \/server\/scripts\/inotify.sh &amp;\n<\/div>\n<p>nohup<\/p>\n<div class=\\\"cnblogs_code\\\">\n<pre>nohup sh inotify.sh &amp;<\/pre>\n<\/div>\n<h2><span id=\\\"27_screen\\\">2.7 screen\u5b9e\u73b0\u811a\u672c\u7a0b\u5e8f\u540e\u53f0\u8fd0\u884c<\/span><\/h2>\n<h3><span id=\\\"271_yumscreenscreen\\\">2.7.1\u00a0\u7ecf\u8fc7yum\u67e5\u627e\u53d1\u73b0screen\u547d\u4ee4\u5c5e\u4e8escreen\u5305<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@test ~]# yum provides screen\nLoaded plugins: fastestmirror, security\nLoading mirror speeds from cached hostfile\n * base: mirrors.aliyun.com\n * epel: mirrors.aliyun.com\n * extras: mirrors.aliyun.com\n * updates: mirrors.aliyun.com\nbase                                                      | 3.7 kB     00:00\nepel                                                      | 4.3 kB     00:00\nextras                                                    | 3.4 kB     00:00\nupdates                                                   | 3.4 kB     00:00\nscreen-4.0.3-19.el6.x86_64 : A screen manager that supports multiple logins on\n                           : one terminal\nRepo        : base\nMatched from:<\/pre>\n<\/div>\n<h3><span id=\\\"272_screen\\\">2.7.2\u00a0\u5b89\u88c5screen\u8f6f\u4ef6<\/span><\/h3>\n<div class=\\\"cnblogs_code\\\">\n<pre>[root@test ~]# yum install -y  screen<\/pre>\n<\/div>\n<h3><span id=\\\"273_screen\\\">2.7.3 screen\u547d\u4ee4\u7684\u53c2\u6570<\/span><\/h3>\n<p>\u5728shell\u4e2d\u8f93\u5165\u00a0screen\u5373\u53ef\u8fdb\u5165screen\u00a0\u89c6\u56fe<\/p>\n<div class=\\\"cnblogs_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\u00a0 screen -ls\u00a0\uff1a\u53ef\u770bscreen\u4f1a\u8bdd<br \/>\nscreen -r ID :\u6307\u5b9a\u8fdb\u5165\u54ea\u4e2ascreen\u4f1a\u8bdd\n<\/div>\n<p><strong>Screen<\/strong><strong>\u547d\u4ee4\u4e2d\u7528\u5230\u7684\u5feb\u6377\u952e<\/strong><\/p>\n<div>\n\u00a0 Ctrl+a c\u00a0\uff1a\u521b\u5efa\u7a97\u53e3<br \/>\nCtrl+a w\u00a0\uff1a\u7a97\u53e3\u5217\u8868<br \/>\nCtrl+a n\u00a0\uff1a\u4e0b\u4e00\u4e2a\u7a97\u53e3<br \/>\nCtrl+a p\u00a0\uff1a\u4e0a\u4e00\u4e2a\u7a97\u53e3<br \/>\nCtrl+a 0-9\u00a0\uff1a\u5728\u7b2c0\u4e2a\u7a97\u53e3\u548c\u7b2c9\u4e2a\u7a97\u53e3\u4e4b\u95f4\u5207\u6362<br \/>\nCtrl+a K(\u5927\u5199)\u00a0\uff1a\u5173\u95ed\u5f53\u524d\u7a97\u53e3\uff0c\u5e76\u4e14\u5207\u6362\u5230\u4e0b\u4e00\u4e2a\u7a97\u53e3\u00a0\uff0c<br \/>\n\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<br \/>\nexit\u00a0\uff1a\u5173\u95ed\u5f53\u524d\u7a97\u53e3\uff0c\u5e76\u4e14\u5207\u6362\u5230\u4e0b\u4e00\u4e2a\u7a97\u53e3<br \/>\n\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<br \/>\nCtrl+a d\u00a0\uff1a\u9000\u51fa\u5f53\u524d\u7ec8\u7aef\uff0c\u8fd4\u56de\u52a0\u8f7dscreen\u524d\u7684shell\u547d\u4ee4\u72b6\u6001<br \/>\nCtrl+a \\&#8221; :\u00a0\u7a97\u53e3\u5217\u8868\u4e0d\u540c\u4e8ew\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c1\u7ae0 \u6570\u636e\u5b9e\u65f6\u540c\u6b65\u4ecb\u7ecd 1.1\u00a0\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 &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=5419\"> <span class=\"screen-reader-text\">inotify+rsync\u5b9e\u73b0\u5b9e\u65f6\u540c\u6b65<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[102,124],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"\u7b2c1\u7ae0 \u6570\u636e\u5b9e\u65f6\u540c\u6b65\u4ecb\u7ecd 1.1\u00a0\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&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/5419"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5419"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/5419\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5419"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}