Incron, tracking file deletion

There is a folder, when uploading files to it, the script is processed using incron with the IN_MODIFY modifier.

What modifier / key should I set for the script to run if one of the files was deleted from the folder?

The user downloads and deletes files from the folder from his Windows machine. The folder is shared using samba.

I tried the modifier - IN_DELETE script does not run. The file names are not known in advance, the folder name is static.

Example settings that work when copying files to a folder (output incrontab-l):

/home/path IN_MODIFY /home/pathwhitscript/script.sh

An example that I mean should run my script when deleting a file from a folder:

/home/path IN_DELETE /home/pathwhitscript/script.sh

The script itself is working. The only question is how to get incron to run the script when deleting a file.

 1
Author: aleksandr barakin, 2016-09-20

1 answers

I suspect that you put both of these lines in incrontab :

/home/path IN_MODIFY /home/pathwhitscript/script.sh
/home/path IN_DELETE /home/pathwhitscript/script.sh

And you get a message like this in the log after saving the file:

Incrond: cannot create watch for user user: (2) No such file or directory

As they say in many places, for example, here, you can not do this: for each monitored directory, there must be only one line, in which several events can be listed separated by commas. and for the definition of, which of the events occurred, pass the variable $% as a parameter to your script. something like this:

/home/path IN_MODIFY,IN_DELETE /home/pathwhitscript/script.sh $%

Other special variables that can be used in the incrontab file are listed in man 5 incrontab.

 3
Author: aleksandr barakin, 2016-09-20 14:25:23