January 22, 2009 Archives

22-01-2009 15:14

Incron

Incron is a cron like daemon that you can set up to execute certain tasks when your file system changes. Much like is brother, cron which is based on time to launch events, incron is based on events from inotify from file system events/activities.

So I began playing with this on my Debian server and had a little trouble to begin with. Debian install of Incron, by default, doesn't allow ANY user to use it, including root. So first up, one need to add the user you want to have access to the incron daemon to /etc/incron.allow file. It is originally blank. Mandriva I found didn't use this system; /etc/incron.allow did not exist and all users had access.

To add an entry in a users incrontab you simply to like you would for cron.

incrontab -e

And then add like example below

/root/test IN_MODIFY touch /root/testing

Right, all looks good now. Hmmmm try editing with VIM and saving a change to /root/test and /root/testing has an up to date time stamp. Wait another min and do it again and no change to /root/testing. Hmmmm a bit of searching found this thread. incron loses track of files edited by vim. This thread suggests its to do with some editing [I assume vim included] use a temp file when editing. So I changed my lines event from IN_MODIFY to IN_ALL_EVENTS and we have lift off [so far...]

The other issue I found was if you can add system wide. I found, through experimenting [and this issue above made this hard to begin with] that you can add files into /etc/incron.d/ that contain line entries matching the format of above and the system will run them.

Incron is a terrific daemon service that I am going to look at implementing into my servers in other ways. It just needs a little better documentation, but not too bad, mostly me trying to do this while doing other things.


Posted by DaveQB | Permanent Link | Categories: IT