Got the inotify app working, so no need for additional shell scripting.
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
Find out the ID of the external storage
www-data@docker:/var/www/html$ php occ files_external:list
Watch the external storage
supervisord.conf file to contain the following:
command=/usr/local/bin/php /var/www/html/occ files_external:notify -v 1
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