ownCloud - occ command

最後更新: 2024-06-05

目錄

 


occ command

 

建立 shotcut

ln -s /INSTALL_PATH/owncloud/occ /usr/sbin/occ

Usage

# 要用執行 PHP(Apache) 的身份來行

e.g.

www-data

否則會有 Error

./occ

Console has to be executed with the user that owns the file config/config.php
Current user: root
Owner of config.php: apache

# 所以要這樣執行

[方法 A]

sudo -u www-data ./occ

[方法 B]

su www-data -s /bin/bash

./occ

version

./occ -V

ownCloud 10.13.2

status

./occ status

  - installed: true
  - first_install_version: 10.13.2.3
  - version: 10.14.0.3
  - versionstring: 10.14.0
  - edition: Community

Help

./occ help app:list

 


修改系統 Settings

 

Get

./occ config:system:get enable_previews

Set

# string(default), integer, double, boolean, json

./occ config:system:set --type=boolean --value=false enable_previews

 


maintenance & files

 

maintenance

  • maintenance:mode                          # set maintenance mode ( --on / --off)
  • maintenance:singleuser                    # set single user mode
  • maintenance:update:htaccess          # Updates the .htaccess file.
  • maintenance:mimetype:update-db    # Update database mimetypes and update filecache
  • maintenance:mimetype:update-js     # Update mimetypelist.js
  • maintenance:repair                          # repair this installation

e.g.

./occ maintenance:mode --on

File 相關

files:scan

# command scans for new files and updates the file cache.

files:scan <--all | USER>

i.e.

sudo -u apache occ files:scan tim

Starting scan for user 1 out of 1 (tim)

+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 3       | 0     | 00:00:00     |
+---------+-------+--------------+

files:checksums:verify

# Get all checksums in filecache and compares them by recalculating the checksum of the file.

occ files:checksums:verify [-u USER-u]        #  不帶參數 = for all users

i.e.

Mismatch for files/welcome.txt:
 Filecache:   SHA1:...
 Actual:  SHA1:...

 


file versions & trashbin

 

versions

versions:expire

# versions_retention_obligation setting in config.php

./occ versions:expire [<user_id>]

versions:cleanup

# to delete file ALL versions

./occ versions:cleanup [<user_id>]

詳見: Files Versioning

trashbin

# remove any file in the ownCloud trash bin which is older than the trashbin_retention_obligation

./occ trashbin:expire

# Remove deleted files (Default ALL user)

./occ trashbin:cleanup [USER]

詳見: 垃圾筒設定

 


User
 

 

Add / Delete Account

e.g.

 

./occ user:add datahunter

Enter password:
Confirm password:
The user "datahunter" was created successfully

# 沒有 double comfirm 的 !!

./occ user:delete datahunter

User with uid 'datahunter', display name 'datahunter', email '' was deleted

Reset Password

./occ  user:resetpassword USERNAME

Checking / Info

./occ user:report

+------------------+---+
| User Report      |   |
+------------------+---+
| OC\User\Database | 2 |
|                  |   |
| guest users      | 0 |
|                  |   |
| total users      | 2 |
|                  |   |
| user directories | 2 |
+------------------+---+

user:list

  - admin: admin
  - datahunter: datahunter

Enable / Disable User Account

user:disable USERNAME

user:enable USERNAME

 


Group

 

./occ group:list

./occ group:list-members admin

./occ group:add-member -m user1 admin

./occ user:list-groups user1

  - admin

./occ group:list-members admin

  - user1: user1

 


System 相關

 

Set background jobs type

jobs type

  • background:ajax           # Use ajax to run background jobs
  • background:cron           # Use cron to run background jobs
  • background:webcron     # Use webcron to run background jobs

./occ background:cron

Notes: 人手行一次 background

# Execute background jobs as cron

./occ system:cron

Checking

background:queue:status

+--------+-------------------------------------------------------+---------------+---------------------------+---------------------------+-------------+------------------------+
| Job ID | Job                                                   | Job Arguments | Last Run                  | Last Checked              | Reserved At | Execution Duration (s) |
+--------+-------------------------------------------------------+---------------+---------------------------+---------------------------+-------------+------------------------+
| 1      | OCA\Files\BackgroundJob\ScanFiles                     |               | 2024-06-12T03:15:02+00:00 | 2024-06-12T03:15:02+00:00 | N/A         | 0                      |
| 2      | OCA\Files\BackgroundJob\DeleteOrphanedItems           |               | 2024-06-12T02:34:36+00:00 | 2024-06-12T03:15:02+00:00 | N/A         | 0                      |
...

 

 


App

 

List

./occ app:list

# output

Enabled:
...
Disabled:
...

Enable an app

./occ app:enable passwordpolicy

 


Other Opts

 

Check App

integrity:check-core                # Check core integrity using a signature.

integrity:check-app                 # Check app integrity using a signature.

 

db

db:convert-type                      # Convert the ownCloud database to the newly configured one

db:generate-change-script       # generates the change script from the current connected db to db_structure.xml

 

 

 

 

 
 
 
 

Creative Commons license icon Creative Commons license icon