Cronjob to detect last modified files Cronjob to detect last modified files shell shell

Cronjob to detect last modified files


There is a Linux utility called incron that can be used similar to normal cron, but rather than events being time based, they work off of inotify and are fired from file events.

You can find the Ubuntu man page here: http://manpages.ubuntu.com/manpages/intrepid/man5/incrontab.5.html

I personally have not had to use it for anything too complex, but it roughly goes like this:

Install it:

sudo apt-get install incron

Open the editor to add an entry:

incrontab -e

Put something like this:

/var/www/myfolder IN_MODIFY curl https://www.example.com/api/file-updated/$#

The first part is the file or folder to watch. The second part is the event. And the third part is the command.

I think that $# is the placeholder for the file in question.