{ "created": "2015-12-20T19:56:47Z", "hierarchy": [ { "name": "ROOT", "type": "folder", "uri": "/ROOT" }, { "name": "Incrond", "type": "article", "uri": "Incrond" } ], "html": "\n\n \n \n \n \n \n \n \n \n \n \n \n Incrond – Nikhil's Personal Wiki\n \n \n \n \n \n
\n
\n \n
\n
\n \n \n\n

Incrond\n \n

\n

incron is an inotify-based cron system.
\nYou can make it do stuff (like trigger a script) when files or
\ndirectories change, are opened, closed, etc (i.e., “filesystem events”).
\nYou need a 2.6.13 kernel or higher to use it.

\n

Installation

\n
# CentOS/RHEL  \nsudo yum install incron --yes  \n\n# Ubuntu  \nsudo apt-get install incron --yes\n
\n

The global config file is /etc/incron.conf. Now make sure you start
\nthe service (might be a good idea to chkconfig this too):

\n
# CentOS/RHEL  \nservice incrond start  \n\n# Ubuntu  \n/etc/init.d/incron start\n
\n

Events

\n

You can get a listing of events by issuing:

\n
[root@example ~]# incrontab -t  \nIN_ACCESS,IN_MODIFY,IN_ATTRIB,IN_CLOSE_WRITE,IN_CLOSE_NOWRITE,IN_OPEN,  \nIN_MOVED_FROM,IN_MOVED_TO,IN_CREATE,IN_DELETE,IN_DELETE_SELF,IN_CLOSE,  \nIN_MOVE,IN_ONESHOT,IN_ALL_EVENTS,IN_DONT_FOLLOW,IN_ONLYDIR,IN_MOVE_SELF\n
\n

You can find an explanation of each in /usr/include/linux/inotify.h.
\nFor example:

\n
26 /* the following are legal, implemented events that user-space can watch for */  \n27 #define IN_ACCESS               0x00000001      /* File was accessed */  \n28 #define IN_MODIFY               0x00000002      /* File was modified */  \n29 #define IN_ATTRIB               0x00000004      /* Metadata changed */  \n30 #define IN_CLOSE_WRITE          0x00000008      /* Writtable file was closed */  \n31 #define IN_CLOSE_NOWRITE        0x00000010      /* Unwrittable file closed */  \n32 #define IN_OPEN                 0x00000020      /* File was opened */  \n33 #define IN_MOVED_FROM           0x00000040      /* File was moved from X */  \n34 #define IN_MOVED_TO             0x00000080      /* File was moved to Y */  \n35 #define IN_CREATE               0x00000100      /* Subfile was created */  \n36 #define IN_DELETE               0x00000200      /* Subfile was deleted */  \n37 #define IN_DELETE_SELF          0x00000400      /* Self was deleted */  \n38 #define IN_MOVE_SELF            0x00000800      /* Self was moved */\n
\n

Creating traps

\n

Start editing your incrontab with incrontab *-e*. Here are some
\nexamples of traps

\n
# Restart the NTP daemon when its config file changes  \n/etc/ntp/ntp.conf IN_MODIFY /sbin/service ntpd restart  \n\n# Run a script with the absolute path to filename as parameter when it changes (and is closed)  \n/home/nanand/thesis.txt IN_WRITE_CLOSE /home/nanand/bin/log_changes.sh $@/$#\n

Here is a full list of wildcards:

\n
$$ - a dollar sign  \n$@ - the watched filesystem path   \n$# - the event-related file name  \n$% - the event flags (textually)  \n$& - the event flags (numerically)\n
\n

Sources

\n\n\n\n
\n \n
\n \n \n \n \n \n\n", "id": "15dacd6d-5ccb-5186-82d5-bad2b2279852", "modified": "2024-04-15T23:13:03Z", "revisions": [ { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2024-04-15T23:13:03Z", "id": "1f343266dce411121f0cff3ca7e3e0632be6ce97", "shortId": "1f343266", "subject": "Some more notes\n", "content": "`incron` is an [inotify](http://inotify.aiken.cz/)-based cron system.\nYou can make it do stuff (like trigger a script) when files or\ndirectories change, are opened, closed, etc (i.e., \"filesystem events\").\nYou need a 2.6.13 kernel or higher to use it.\n\nInstallation\n------------\n\n # CentOS/RHEL \n sudo yum install incron --yes \n \n # Ubuntu \n sudo apt-get install incron --yes\n\nThe global config file is `/etc/incron.conf`. Now make sure you start\nthe service (might be a good idea to `chkconfig` this too):\n\n # CentOS/RHEL \n service incrond start \n \n # Ubuntu \n /etc/init.d/incron start\n\nEvents\n------\n\nYou can get a listing of events by issuing:\n\n [root@example ~]# incrontab -t \n IN_ACCESS,IN_MODIFY,IN_ATTRIB,IN_CLOSE_WRITE,IN_CLOSE_NOWRITE,IN_OPEN, \n IN_MOVED_FROM,IN_MOVED_TO,IN_CREATE,IN_DELETE,IN_DELETE_SELF,IN_CLOSE, \n IN_MOVE,IN_ONESHOT,IN_ALL_EVENTS,IN_DONT_FOLLOW,IN_ONLYDIR,IN_MOVE_SELF\n\nYou can find an explanation of each in `/usr/include/linux/inotify.h`.\nFor example:\n\n 26 /* the following are legal, implemented events that user-space can watch for */ \n 27 #define IN_ACCESS               0x00000001      /* File was accessed */ \n 28 #define IN_MODIFY               0x00000002      /* File was modified */ \n 29 #define IN_ATTRIB               0x00000004      /* Metadata changed */ \n 30 #define IN_CLOSE_WRITE          0x00000008      /* Writtable file was closed */ \n 31 #define IN_CLOSE_NOWRITE        0x00000010      /* Unwrittable file closed */ \n 32 #define IN_OPEN                 0x00000020      /* File was opened */ \n 33 #define IN_MOVED_FROM           0x00000040      /* File was moved from X */ \n 34 #define IN_MOVED_TO             0x00000080      /* File was moved to Y */ \n 35 #define IN_CREATE               0x00000100      /* Subfile was created */ \n 36 #define IN_DELETE               0x00000200      /* Subfile was deleted */ \n 37 #define IN_DELETE_SELF          0x00000400      /* Self was deleted */ \n 38 #define IN_MOVE_SELF            0x00000800      /* Self was moved */\n\nCreating traps\n--------------\n\nStart editing your incrontab with `incrontab *-e*`. Here are some\nexamples of traps\n\n```bash\n# Restart the NTP daemon when its config file changes \n/etc/ntp/ntp.conf IN_MODIFY /sbin/service ntpd restart \n\n# Run a script with the absolute path to filename as parameter when it changes (and is closed) \n/home/nanand/thesis.txt IN_WRITE_CLOSE /home/nanand/bin/log_changes.sh $@/$#\n```\n\nHere is a full list of wildcards:\n\n $$ - a dollar sign \n $@ - the watched filesystem path  \n $# - the event-related file name \n $% - the event flags (textually) \n $& - the event flags (numerically)\n\nSources\n-------\n\n- `/usr/share/doc/incron/README` (Ubuntu)\n- `/usr/share/doc/incron-0.5.5/README` (CentOS/RHEL)\n" }, { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2015-12-27T07:27:56Z", "id": "5a5b1a32f41081d062ab86f8869a961bcad79668", "shortId": "5a5b1a32", "subject": "Fix Markdown conversion\n\nSaw half a season of The Office\n", "content": "`incron` is an [inotify](http://inotify.aiken.cz/)-based cron system.\nYou can make it do stuff (like trigger a script) when files or\ndirectories change, are opened, closed, etc (i.e., \"filesystem events\").\nYou need a 2.6.13 kernel or higher to use it.\n\nInstallation\n------------\n\n # CentOS/RHEL \n sudo yum install incron --yes \n \n # Ubuntu \n sudo apt-get install incron --yes\n\nThe global config file is `/etc/incron.conf`. Now make sure you start\nthe service (might be a good idea to `chkconfig` this too):\n\n # CentOS/RHEL \n service incrond start \n \n # Ubuntu \n /etc/init.d/incron start\n\nEvents\n------\n\nYou can get a listing of events by issuing:\n\n [root@example ~]# incrontab -t \n IN_ACCESS,IN_MODIFY,IN_ATTRIB,IN_CLOSE_WRITE,IN_CLOSE_NOWRITE,IN_OPEN, \n IN_MOVED_FROM,IN_MOVED_TO,IN_CREATE,IN_DELETE,IN_DELETE_SELF,IN_CLOSE, \n IN_MOVE,IN_ONESHOT,IN_ALL_EVENTS,IN_DONT_FOLLOW,IN_ONLYDIR,IN_MOVE_SELF\n\nYou can find an explanation of each in `/usr/include/linux/inotify.h`.\nFor example:\n\n 26 /* the following are legal, implemented events that user-space can watch for */ \n 27 #define IN_ACCESS               0x00000001      /* File was accessed */ \n 28 #define IN_MODIFY               0x00000002      /* File was modified */ \n 29 #define IN_ATTRIB               0x00000004      /* Metadata changed */ \n 30 #define IN_CLOSE_WRITE          0x00000008      /* Writtable file was closed */ \n 31 #define IN_CLOSE_NOWRITE        0x00000010      /* Unwrittable file closed */ \n 32 #define IN_OPEN                 0x00000020      /* File was opened */ \n 33 #define IN_MOVED_FROM           0x00000040      /* File was moved from X */ \n 34 #define IN_MOVED_TO             0x00000080      /* File was moved to Y */ \n 35 #define IN_CREATE               0x00000100      /* Subfile was created */ \n 36 #define IN_DELETE               0x00000200      /* Subfile was deleted */ \n 37 #define IN_DELETE_SELF          0x00000400      /* Self was deleted */ \n 38 #define IN_MOVE_SELF            0x00000800      /* Self was moved */\n\nCreating traps\n--------------\n\nStart editing your incrontab with `incrontab *-e*`. Here are some\nexamples of traps\n\n```bash\n# Restart the NTP daemon when its config file changes \n/etc/ntp/ntp.conf IN_MODIFY /sbin/service ntpd restart \n\n# Run a script with the absolute path to filename as parameter when it changes (and is closed) \n/home/nanand/thesis.txt IN_WRITE_CLOSE /home/nanand/bin/log_changes.sh $@/$#\n```\n\nHere is a full list of wildcards:\n\n $$ - a dollar sign \n $@ - the watched filesystem path  \n $# - the event-related file name \n $% - the event flags (textually) \n $& - the event flags (numerically)\n\nSources\n-------\n\n- `/usr/share/doc/incron/README` (Ubuntu)\n- `/usr/share/doc/incron-0.5.5/README` (CentOS/RHEL)\n" }, { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2015-12-21T02:30:47Z", "id": "3f2c54b1d767218fcb4855fbac306b015afaf551", "shortId": "3f2c54b1", "subject": "Incremental\n", "content": "`incron` is an [inotify](http://inotify.aiken.cz/)-based cron system.\nYou can make it do stuff (like trigger a script) when files or\ndirectories change, are opened, closed, etc (i.e., \"filesystem events\").\nYou need a 2.6.13 kernel or higher to use it.\n\nInstallation\n------------\n\n`# CentOS/RHEL` \n`sudo yum install incron --yes` \n \n`# Ubuntu` \n`sudo apt-get install incron --yes`\n\nThe global config file is `/etc/incron.conf`. Now make sure you start\nthe service (might be a good idea to `chkconfig` this too):\n\n`# CentOS/RHEL` \n`service incrond start` \n \n`# Ubuntu` \n`/etc/init.d/incron start`\n\nEvents\n------\n\nYou can get a listing of events by issuing:\n\n`[root@example ~]# incrontab `**`-t`** \n`IN_ACCESS,IN_MODIFY,IN_ATTRIB,IN_CLOSE_WRITE,IN_CLOSE_NOWRITE,IN_OPEN,` \n`IN_MOVED_FROM,IN_MOVED_TO,IN_CREATE,IN_DELETE,IN_DELETE_SELF,IN_CLOSE,` \n`IN_MOVE,IN_ONESHOT,IN_ALL_EVENTS,IN_DONT_FOLLOW,IN_ONLYDIR,IN_MOVE_SELF`\n\nYou can find an explanation of each in `/usr/include/linux/inotify.h`.\nFor example:\n\n`26 /* the following are legal, implemented events that user-space can watch for */` \n`27 #define IN_ACCESS               0x00000001      /* File was accessed */` \n`28 #define IN_MODIFY               0x00000002      /* File was modified */` \n`29 #define IN_ATTRIB               0x00000004      /* Metadata changed */` \n`30 #define IN_CLOSE_WRITE          0x00000008      /* Writtable file was closed */` \n`31 #define IN_CLOSE_NOWRITE        0x00000010      /* Unwrittable file closed */` \n`32 #define IN_OPEN                 0x00000020      /* File was opened */` \n`33 #define IN_MOVED_FROM           0x00000040      /* File was moved from X */` \n`34 #define IN_MOVED_TO             0x00000080      /* File was moved to Y */` \n`35 #define IN_CREATE               0x00000100      /* Subfile was created */` \n`36 #define IN_DELETE               0x00000200      /* Subfile was deleted */` \n`37 #define IN_DELETE_SELF          0x00000400      /* Self was deleted */` \n`38 #define IN_MOVE_SELF            0x00000800      /* Self was moved */`\n\nCreating traps\n--------------\n\nStart editing your incrontab with `incrontab '''-e'''`. Here are some\nexamples of traps\n\n`# Restart the NTP daemon when its config file changes` \n`/etc/ntp/ntp.conf IN_MODIFY /sbin/service ntpd restart` \n \n`# Run a script with the absolute path to filename as parameter when it changes (and is closed)` \n`/home/nanand/thesis.txt IN_WRITE_CLOSE /home/nanand/bin/log_changes.sh $@/$#`\n\nHere is a full list of wildcards:\n\n`$$ - a dollar sign` \n`$@ - the watched filesystem path ` \n`$# - the event-related file name` \n`$% - the event flags (textually)` \n`$& - the event flags (numerically)`\n\nSources\n-------\n\n- `/usr/share/doc/incron/README` \n (Ubuntu)\n- `/usr/share/doc/incron-0.5.5/README` \n (CentOS/RHEL)\n" }, { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2015-12-20T19:56:47Z", "id": "44e40acdc5de169e02ebe06441d109c88400f988", "shortId": "44e40acd", "subject": "Incrond : First Draft", "content": "`incron` is an [inotify](http://inotify.aiken.cz/)-based cron system.\nYou can make it do stuff (like trigger a script) when files or\ndirectories change, are opened, closed, etc (i.e., \"filesystem events\").\nYou need a 2.6.13 kernel or higher to use it.\n\nInstallation\n------------\n\n`# CentOS/RHEL` \n`sudo yum install incron --yes` \n \n`# Ubuntu` \n`sudo apt-get install incron --yes`\n\nThe global config file is `/etc/incron.conf`. Now make sure you start\nthe service (might be a good idea to `chkconfig` this too):\n\n`# CentOS/RHEL` \n`service incrond start` \n \n`# Ubuntu` \n`/etc/init.d/incron start`\n\nEvents\n------\n\nYou can get a listing of events by issuing:\n\n`[root@example ~]# incrontab `**`-t`** \n`IN_ACCESS,IN_MODIFY,IN_ATTRIB,IN_CLOSE_WRITE,IN_CLOSE_NOWRITE,IN_OPEN,` \n`IN_MOVED_FROM,IN_MOVED_TO,IN_CREATE,IN_DELETE,IN_DELETE_SELF,IN_CLOSE,` \n`IN_MOVE,IN_ONESHOT,IN_ALL_EVENTS,IN_DONT_FOLLOW,IN_ONLYDIR,IN_MOVE_SELF`\n\nYou can find an explanation of each in `/usr/include/linux/inotify.h`.\nFor example:\n\n`26 /* the following are legal, implemented events that user-space can watch for */` \n`27 #define IN_ACCESS               0x00000001      /* File was accessed */` \n`28 #define IN_MODIFY               0x00000002      /* File was modified */` \n`29 #define IN_ATTRIB               0x00000004      /* Metadata changed */` \n`30 #define IN_CLOSE_WRITE          0x00000008      /* Writtable file was closed */` \n`31 #define IN_CLOSE_NOWRITE        0x00000010      /* Unwrittable file closed */` \n`32 #define IN_OPEN                 0x00000020      /* File was opened */` \n`33 #define IN_MOVED_FROM           0x00000040      /* File was moved from X */` \n`34 #define IN_MOVED_TO             0x00000080      /* File was moved to Y */` \n`35 #define IN_CREATE               0x00000100      /* Subfile was created */` \n`36 #define IN_DELETE               0x00000200      /* Subfile was deleted */` \n`37 #define IN_DELETE_SELF          0x00000400      /* Self was deleted */` \n`38 #define IN_MOVE_SELF            0x00000800      /* Self was moved */`\n\nCreating traps\n--------------\n\nStart editing your incrontab with `incrontab '''-e'''`. Here are some\nexamples of traps\n\n`# Restart the NTP daemon when its config file changes` \n`/etc/ntp/ntp.conf IN_MODIFY /sbin/service ntpd restart` \n \n`# Run a script with the absolute path to filename as parameter when it changes (and is closed)` \n`/home/nanand/thesis.txt IN_WRITE_CLOSE /home/nanand/bin/log_changes.sh $@/$#`\n\nHere is a full list of wildcards:\n\n`$$ - a dollar sign` \n`$@ - the watched filesystem path ` \n`$# - the event-related file name` \n`$% - the event flags (textually)` \n`$& - the event flags (numerically)`\n\nSources\n-------\n\n- `/usr/share/doc/incron/README` \n (Ubuntu)\n- `/usr/share/doc/incron-0.5.5/README` \n (CentOS/RHEL)\n\n[Category:Nikhil's Notes](Category:Nikhil's_Notes \"wikilink\")\n[Category:From a past sysadmin\nlife](Category:From_a_past_sysadmin_life \"wikilink\")\n" } ], "sizeInBytes": 3254, "source": "`incron` is an [inotify](http://inotify.aiken.cz/)-based cron system.\nYou can make it do stuff (like trigger a script) when files or\ndirectories change, are opened, closed, etc (i.e., \"filesystem events\").\nYou need a 2.6.13 kernel or higher to use it.\n\nInstallation\n------------\n\n # CentOS/RHEL \n sudo yum install incron --yes \n \n # Ubuntu \n sudo apt-get install incron --yes\n\nThe global config file is `/etc/incron.conf`. Now make sure you start\nthe service (might be a good idea to `chkconfig` this too):\n\n # CentOS/RHEL \n service incrond start \n \n # Ubuntu \n /etc/init.d/incron start\n\nEvents\n------\n\nYou can get a listing of events by issuing:\n\n [root@example ~]# incrontab -t \n IN_ACCESS,IN_MODIFY,IN_ATTRIB,IN_CLOSE_WRITE,IN_CLOSE_NOWRITE,IN_OPEN, \n IN_MOVED_FROM,IN_MOVED_TO,IN_CREATE,IN_DELETE,IN_DELETE_SELF,IN_CLOSE, \n IN_MOVE,IN_ONESHOT,IN_ALL_EVENTS,IN_DONT_FOLLOW,IN_ONLYDIR,IN_MOVE_SELF\n\nYou can find an explanation of each in `/usr/include/linux/inotify.h`.\nFor example:\n\n 26 /* the following are legal, implemented events that user-space can watch for */ \n 27 #define IN_ACCESS               0x00000001      /* File was accessed */ \n 28 #define IN_MODIFY               0x00000002      /* File was modified */ \n 29 #define IN_ATTRIB               0x00000004      /* Metadata changed */ \n 30 #define IN_CLOSE_WRITE          0x00000008      /* Writtable file was closed */ \n 31 #define IN_CLOSE_NOWRITE        0x00000010      /* Unwrittable file closed */ \n 32 #define IN_OPEN                 0x00000020      /* File was opened */ \n 33 #define IN_MOVED_FROM           0x00000040      /* File was moved from X */ \n 34 #define IN_MOVED_TO             0x00000080      /* File was moved to Y */ \n 35 #define IN_CREATE               0x00000100      /* Subfile was created */ \n 36 #define IN_DELETE               0x00000200      /* Subfile was deleted */ \n 37 #define IN_DELETE_SELF          0x00000400      /* Self was deleted */ \n 38 #define IN_MOVE_SELF            0x00000800      /* Self was moved */\n\nCreating traps\n--------------\n\nStart editing your incrontab with `incrontab *-e*`. Here are some\nexamples of traps\n\n```bash\n# Restart the NTP daemon when its config file changes \n/etc/ntp/ntp.conf IN_MODIFY /sbin/service ntpd restart \n\n# Run a script with the absolute path to filename as parameter when it changes (and is closed) \n/home/nanand/thesis.txt IN_WRITE_CLOSE /home/nanand/bin/log_changes.sh $@/$#\n```\n\nHere is a full list of wildcards:\n\n $$ - a dollar sign \n $@ - the watched filesystem path  \n $# - the event-related file name \n $% - the event flags (textually) \n $& - the event flags (numerically)\n\nSources\n-------\n\n- `/usr/share/doc/incron/README` (Ubuntu)\n- `/usr/share/doc/incron-0.5.5/README` (CentOS/RHEL)\n", "title": "Incrond", "untracked": false, "uri": "/Incrond", "relativePath": "Incrond.md" }