Sometimes, one wants to put a nextcloud installation into “Maintenance mode” from the command line. Assuming your nextcloud is installed in /var/www/nextcloud/, the following command will put it in maintenance mode:
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on
The following command will deactivate maintenance mode:
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off
If you want to check the state of maintenance mode:
if [ "$(sudo -u www-data php /var/www/nextcloud/occ status | grep -c "maintenance: true")" != "0" ]; then
echo "Nextcloud is in maintenance mode"
else
echo "Nextcloud is not in maintenance mode"
fi
(Last update on September 2, 2026 was done by Editor F.)