Suggestion: Watch Directory, Then Trigger A Script

My goal is to watch a directory of photos (in my Nextcloud folder), and once new photos are uploaded there, I want to run a script that moves them to my backup drive with rsync. Then, I want to run a photo indexing job on them (with Photoprism), and get the script to wait a bit before checking the watched directory (maybe 1 hour sleep?)

I currently have a script to do all this but I run it every night using cron. I would prefer to have the photos be updated/indexed once they are available to the server.

I am wondering what are the best tools to accomplish this in Yunohost.

  1. What should I use to watch the directory? inotify, incron or something else?
  2. Where should I run the ‘watch the directory’ script? Use systemd/rc.local or cron or something else?

Feedback and suggestions would be appreciated.