• Contact
  • About Me
  • Privacy Policy
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
No Result
View All Result
DefenceDev
No Result
View All Result
ADVERTISEMENT
Home Projects Nextcloud

Nextcloud: Maintenance with OCC Command with Practical Examples

neo by neo
May 27, 2025
in Nextcloud
0
Nextcloud: Maintenance with OCC Command with Practical Examples

Nextcloud: Maintenance with OCC Command with Practical Examples

0
SHARES
249
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

Maintenance with OCC Command

In this article, we’ll walk through various maintenance tasks that can be performed with occ command. I will present you practical examples to disable or enable maintenance mode, optimize your Nextcloud instance, optimizing the database and more.

Whether you’re looking to manage file caching or configure system-wide updates, the occ command is an essential tool for every Nextcloud administrator.

Nextcloud’s occ command (origins from “ownCloud Console”) is Nextcloud’s command-line interface. You can perform many common server operations with occ, such as installing and upgrading Nextcloud, manage users, encryption, passwords, LDAP setting, and more.

Prerequisites for Nextcloud Maintenance with occ Command

occ is in the nextcloud/ directory; for example /var/www/nextcloud on Ubuntu Linux. occ is a PHP script. You must run it as your HTTP user to ensure that the correct permissions are maintained on your Nextcloud files and directories.

Practical Examples of occ Command for Maintenance Tasks

Before executing occ command, you need to navigate to the Nextcloud directory. In my case, it is in the

cd /var/www/html/nextcloud

Check Nextcloud System Status

To check system status, you can execute the following command in your Nextxloud directory:

sudo -u www-data php occ status

Output is something like:

root@nextcloud:/var/www/html/nextcloud# sudo -u www-data php occ status
  - installed: true
  - version: 30.0.3.2
  - versionstring: 30.0.3
  - edition:
  - maintenance: false
  - needsDbUpgrade: false
  - productname: Nextcloud
  - extendedSupport: false

Scan the Files and Optimize the File Cache

sudo -u www-data php occ files:scan --all
Output of occ files:scan command
Output f occ files:scan command

Enable or Disable Maintenance Mode

To disable maintenance mode, you can execute the following command:

# Enable Maintenance Mode
sudo -u www-data php occ maintenance:mode --on

# Disable Maintenance Mode
sudo -u www-data php occ maintenance:mode --off

Listing Installed Apps

To list all installed application on your Nextcloud Server, you can execute:

ADVERTISEMENT
sudo -u www-data php occ app:list

In my case, there are a lot of installed application:

ADVERTISEMENT
Enabled:
  - activity: 3.0.0
  - admin_audit: 1.20.0
  - app_api: 4.0.3
  - audioplayer: 3.4.1
  - bruteforcesettings: 3.0.0
  - cloud_federation_api: 1.13.0
  - comments: 1.20.1
  - contactsinteraction: 1.11.0
  - cospend: 2.0.0
  - dashboard: 7.10.0
  - dav: 1.31.1
  - federatedfilesharing: 1.20.0
  - files: 2.2.0
  - files_accesscontrol: 1.20.1
  - files_downloadlimit: 3.0.0
  - files_pdfviewer: 3.0.0
  - files_reminders: 1.3.0
  - files_sharing: 1.22.0
  - files_trashbin: 1.20.1
  - files_versions: 1.23.0
  - firstrunwizard: 3.0.0
  - geoblocker: 0.5.15
  - groupfolders: 18.0.7
  - groupquota: 0.2.1
  - login_notes: 1.6.1
  - logreader: 3.0.0
  - lookup_server_connector: 1.18.0
  - memories: 7.4.1
  - nextcloud_announcements: 2.0.0
  - notes: 4.11.0
  - notifications: 3.0.0
  - oauth2: 1.18.1
  - password_policy: 2.0.0
  - photos: 3.0.2
  - privacy: 2.0.0
  - provisioning_api: 1.20.0
  - quota_warning: 1.20.0
  - related_resources: 1.5.0
  - serverinfo: 2.0.0
  - settings: 1.13.0
  - sharebymail: 1.20.0
  - spreed: 20.1.0
  - suspicious_login: 8.0.0
  - text: 4.1.0
  - theming: 2.5.0
  - twofactor_backupcodes: 1.19.0
  - updatenotification: 1.20.0
  - user_status: 1.10.0
  - viewer: 3.0.0
  - webhook_listeners: 1.1.0-dev
  - workflowengine: 2.12.0
Disabled:
  - circles: 30.0.0 (installed 25.0.0)
  - encryption: 2.18.0
  - federation: 1.20.0 (installed 1.18.0)
  - files_external: 1.22.0
  - recommendations: 3.0.0 (installed 1.3.0)
  - support: 2.0.0 (installed 1.7.0)
  - survey_client: 2.0.0 (installed 1.16.0)
  - systemtags: 1.20.0 (installed 1.18.0)
  - twofactor_nextcloud_notification: 4.0.0
  - twofactor_totp: 12.0.0-dev
  - user_ldap: 1.21.0
  - weather_status: 1.10.0 (installed 1.9.0)
  - workflow_media_converter: 1.11.7 (installed 1.11.7)

Database Maintenance After Nextcloud Upgrade

After upgrading my Nextcloud environment, I am running the following occ command to optimize Database:

IMPORTANT: Create a backup of DB before running this command!

mysqldump -u root -p nextcloud > backup.sql

Add missing primary keys:

sudo -u www-data php occ db:add-missing-primary-keys

sudo -u www-data php occ db:add-missing-indices
sudo -u www-data php occ db:convert-filecache-bigint

Output:


root@nextcloud:/var/www/html$  sudo -u www-data php occ db:add-missing-primary-keys
Done.

Other Useful occ Commands Examples

Running occ with no options lists all commands and options, like this example on Ubuntu:

ADVERTISEMENT
 sudo -u www-data php occ

Example of output:

 maintenance
  maintenance:data-fingerprint                    update the systems data-fingerprint after a backup is restored
  maintenance:mimetype:update-db                  Update database mimetypes and update filecache
  maintenance:mimetype:update-js                  Update mimetypelist.js
  maintenance:mode                                set maintenance mode
  maintenance:repair                              repair this installation
  maintenance:repair-share-owner                  repair invalid share-owner entries in the database
  maintenance:theme:update                        Apply custom theme changes
  maintenance:update:htaccess                     Updates the .htaccess file

Please check other Nextcloud topics on my blog.

Nextcloud: Maintenance with OCC Command with Practical Examples

defencedev.com

About The Author

neo

See author's posts

Tags: nextcloud
ADVERTISEMENT
Previous Post

Linux Networking: netplan Network Configuration on Ubuntu

Next Post

Solutions: Check Disk Usage on Ubuntu Terminal with ncdu Application

neo

neo

Next Post
Solutions: Check Disk Usage on Ubuntu Terminal with ncdu Application

Solutions: Check Disk Usage on Ubuntu Terminal with ncdu Application

Follow Us

  • Trending
  • Comments
  • Latest
MikroTik: Export Configuration in Text File

MikroTik: Export Configuration in Text File

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Immich: Installation on Ubuntu 22.04

Immich: Installation on Ubuntu 22.04

Fortinet FortiGate Upgrade Path Tool

Fortinet FortiGate Upgrade Path Tool

NextCloud: Port Forwarding - Essential Ports for Smooth Functionality

NextCloud: Port Forwarding – Essential Ports for Smooth Functionality and Remote Access

Organizing and Managing Photos with Immich: Features I Use

Organizing and Managing Photos with Immich: Features I Use

Install Ubuntu 22.04 on Oracle VM Virtual Box

Install Ubuntu 22.04 on Oracle VM Virtual Box

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Recent News

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

MikroTik: Check Your Wireless Password

MikroTik: Check Your Wireless Password

ADVERTISEMENT

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Browse by Category

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos

Recent News

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

  • Site Map
  • Privacy Policy
  • Facebook Page
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos

© 2025 defencedev.com - All rights reserved.