sudo -u www-data php occ files:scan --help
Usage:
files:scan [options] [--] [<user_id>]...
Arguments:
user_id Will rescan all files of the given user(s)
Options:
--output[=OUTPUT] Output format (plain, json or json_pretty, default is plain) [default: "plain"]
-p, --path=PATH Limit rescan to this path, eg. --path="/alice/files/Music", the user_id is determined by the path and the user_id parameter and --all are ignored
-g, --groups=GROUPS Scan user(s) under the group(s). This option can be used as --groups=foo,bar to scan groups foo and bar
-q, --quiet Do not output any message
--all Will rescan all files of all known users
--repair Will repair detached filecache entries (slow)
--unscanned Only scan files which are marked as not fully scanned
-h, --help Display this help message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--no-warnings Skip global warnings, show command output only
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
but why you make this manually, it should work automatical.