Got the inotify app working, so no need for additional shell scripting.
For posteriority:
How to watch a local external storage directory for changes
This is with a Dockerized set-up. You’ll want to base this off the example Dockerfile for cron job support because this includes the supervisord process manager.
Install and enable the inotify app within your Nextcloud instance
https://apps.nextcloud.com/apps/files_inotify
Find out the ID of the external storage
www-data@docker:/var/www/html$ php occ files_external:list
Watch the external storage
Amend your supervisord.conf file to contain the following:
[program:watch_external]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
command=/usr/local/bin/php /var/www/html/occ files_external:notify -v 1
user=www-data
important bits here are the user=www-data line because occ will refuse to operate unless executed as the user who owns the Nextcloud configuration file, which is www-data in the Dockerized setup.
If your external storage ID is not 1, replace -v 1 with whatever is correct for your case.
Don’t forget to restart your Docker image 