This script run an unattended update for installed nextcloud apps, the nextcloud installation itself and runs database fixes.
nextcloud-auto-update <NEXTCLOUD_DIRECTORY>
To run it peridically with CRON:
0 3 * * * www-data <PATH_TO_NEXTCLOUD_AUTO_UPDATE> <NEXTCLOUD_DIRECTORY>