# How to automatically detect new files in external storage

**URL:** <https://help.nextcloud.com/t/how-to-automatically-detect-new-files-in-external-storage/84871>\
**Category:** ℹ️ Support\
**Tags:** external\_storage\
**Created:** [June 16, 2020, 6:43pm UTC](https://help.nextcloud.com/t/how-to-automatically-detect-new-files-in-external-storage/84871 "2020-06-16T18:43:09Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![bovender](https://help.nextcloud.com/user_avatar/help.nextcloud.com/bovender/32/6943_2.png) [@bovender](https://help.nextcloud.com/u/bovender)\
**Post date:** [June 20, 2020, 3:50am UTC](https://help.nextcloud.com/t/how-to-automatically-detect-new-files-in-external-storage/84871/5 "2020-06-20T03:50:52Z")

</div>

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](https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles/cron/apache) because this includes the [supervisord](http://supervisord.org) process manager.

## Install and enable the inotify app within your Nextcloud instance

[https://apps.nextcloud.com/apps/files\_inotify](https://apps.nextcloud.com/apps/files_inotify)

## Find out the ID of the external storage

```auto
www-data@docker:/var/www/html$ php occ files_external:list

```

## Watch the external storage

Amend your `supervisord.conf` file to contain the following:

```auto
[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 😉

---

_[View the full topic](https://help.nextcloud.com/t/how-to-automatically-detect-new-files-in-external-storage/84871)._
