Automation – How to Put a Trigger on a Directory

automation

I have a script that scans a directory and does some maintenance on the files in it. Another process creates the files in the directory (10 – 30 files per day).

The script is called via a daily cron job . What I need is to trigger the script on an event (each time a new file is created in the directory). I prefer this rather than increasing the frequency of the cron job.

How can I do that? is there a command or a program to install?

Thanks in advance for any help.

Best Answer

inoticoming

inoticoming is a daemon to watch a directory with Linux's inotify framework and trigger actions once files with specific names are placed in there.

For example it can be used to wait for .changes files uploaded into a directory and call reprepro to put them into your repository.

incron

incron is an "inotify cron" system. It works like the regular cron but is driven by filesystem events instead of time events. This package provides two programs, a daemon called "incrond" (analogous to crond) and a table manipulator "incrontab" (like "crontab").

incron uses the Linux Kernel inotify syscalls.

like cron, each user can edit its own incron tables.