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

What modifier / key to install, so that the script is executed if one of the files is deleted from the folder?

The user downloads and deletes files from his folder from his Windows machine. Folder shared by samba.

Tried the modifier - IN_DELETE script does not run. File names are not known in advance, the folder name is static.

An example of a setting that works when copying files to a folder (output incrontab -l):

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

An example that, as 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 make incron run the script when the file is deleted.

  • the script does not start - you, it seems, are not using ru.so for the first day, and should understand that the given expression requires expansion in the form of the minimum reproducible example - aleksandr barakin
  • An example of a script does not think that it is required it does not apply to the question. The question is how to run it through incron when deleting a file from the folder. - Evgeniy A
  • The content of your script is absolutely unimportant. but in the “minimal self-sufficient and reproducible example” there should be something like an echo тест >> /tmp/file . and information about whether something appeared in the file, and if not, what errors were issued by the incron program. - aleksandr barakin

1 answer 1

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

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

and get in the log after saving the file a message like:

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

as they write in many places, for example, here , it is impossible to do this: for each monitored directory there should be only one line in which several events can be listed separated by commas. and to determine which of the events exactly happened, pass the $% variable to the parameter to your script. like that:

 /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 .

  • That's right, the error was that at the same time I used two lines for each folder. Comma, earned. - Evgeniy A