Incron: easy use of the inotify system

This is just a short post, to point out the convenience of a tool named ‘incron‘. Incron is described as an ‘inotify cron‘ system. It behaves much like traditional cron, but instead of time periods, filesystem events are used to trigger certain actions.

In my daily work, quite often I come across situations, where I have to post-process files, that are uploaded to a certain place. For example, a third party regularly uploads video files to one of our servers, and when they do, I have to make sure they are transcoded to a different audio and video format. Enter ‘incron’. It allows you, in a crontab kind of way to define commands, that have to be executed when certain files or directories change.

I have an incron-tab entry, that looks like this:

/home/vod/videofiles IN_MOVED_TO /usr/local/bin/process_upload $#

/home/vod/videofiles is a directory, and when a file is moved into that directory (which is done by the uploading party, through the FTP server) and subsequently the inotify event ‘IN_MOVED_TO‘ is triggered, the process_upload script is fired, with the name of the file (specified as ‘$#‘) as its first argument. Couldn’t be simpler.

Take a look at incron’s web page for more use cases, examples and documentation.

Both comments and pings are currently closed.

Comments are closed.