一、索引全部内容

1、查看容器名称

输入以下指令

k3s kubectl -n ix-nextcloud get pods

输入完成后你将得到以下返回值

root@truenas[~]# k3s kubectl -n ix-nextcloud get pods
NAME                                 READY   STATUS    RESTARTS   AGE
nextcloud-redis-77d7465d6-hb9qm      1/1     Running   0          11d
nextcloud-postgres-8757698c5-4plld   1/1     Running   0          11d
nextcloud-76b679cff8-ldl7m           1/1     Running   0          11d

其中nextcloud-76b679cff8-ldl7m就为目标的容器名称

2、开始索引全部内容 --all

输入以下指令,注意需要sudo权限,将你的容器名称替换为第一步中获取到的容器名称

sudo k3s kubectl -n ix-nextcloud exec 你的容器名称 -c nextcloud -- su - www-data -s /bin/sh -c "php /var/www/html/occ files:scan --all"

然后等待索引完成即可,索引结果示例如下

root@truenas[~]# sudo k3s kubectl -n ix-nextcloud exec nextcloud-76b679cff8-ldl7m  -c nextcloud -- su - www-data -s /bin/sh -c "php /var/www/html/occ files:scan --all"

Warning: Failed to set memory limit to 0 bytes (Current memory usage is 2097152 bytes) in Unknown on line 0
The current PHP memory limit is below the recommended value of 512MB.
Starting scan for user 1 out of 6 (User1)
Starting scan for user 2 out of 6 (User2)
Starting scan for user 3 out of 6 (User3)
Starting scan for user 4 out of 6 (User4)
Starting scan for user 5 out of 6 (User5)
Starting scan for user 6 out of 6 (User6)
+---------+--------+-----+---------+---------+--------+--------------+
| Folders | Files  | New | Updated | Removed | Errors | Elapsed time |
+---------+--------+-----+---------+---------+--------+--------------+
| 15430   | 319466 | 0   | 278     | 0       | 0      | 00:04:41     |
+---------+--------+-----+---------+---------+--------+--------------+

二、索引指定目录内容

1、如上操作获取容器名称

输入以下指令获取容器名称,这步和上面的步骤一致

k3s kubectl -n ix-nextcloud get pods

2、开始索引指定目录内容

输入以下指令,注意需要sudo权限,将你的容器名称替换为第一步中获取到的容器名称 注意:首目录需要精确到data下用户的目录

sudo k3s kubectl -n ix-nextcloud exec 你的容器名称 -c nextcloud -- su - www-data -s /bin/sh -c "php /var/www/html/occ files:scan --path 指定索引目录"

然后等待索引完成即可