Hosting your own instance of Nextcloud offers the additionl advantage of server-side scripting and task automation.

Server-side commands

The occ command line utility is used by navigating to the root installation folder of your Nextcloud instance and, using your appropriate web-user and php installation, run as outlined below:

sudo -u www-data php7.4 occ help

www-data, php7.4 and username may be substituted for values appropriate to your installation.

List available commands

sudo -u www-data php occ list

Notable commands

Requires maintenance:mode --off:

  • sharing:cleanup-remote-storages
  • trashbin:cleanup --all-users

Can be run with maintenance:mode --on:

  • update:check
  • app:update --all
  • maintenance:mode --on\off
  • notification:generate **username** "255 char message" -l "4000 char optional message"
  • background:cron

For a Nextcloud 20 installation, the argument flags are explained in detail in the official documentation.

Assigning commands to cron

For a general crontab generator, see the crontab guru page. Below are some useful examples.

Nextcloud standard cron running every 15 mins:

  • */15 * * * * sudo -u www-data php /var/www/NEXTCLOUD/cron.php