Automate NextCloud updates

Here is my script to automate NextCloud updates. They can be put into crontab in example:

#!/bin/csh

setenv nextcloud "/usr/local/www/nextcloud"

pushd $nextcloud
sudo -u www -D $nextcloud /usr/local/bin/php --define apc.enable_cli=1 updater/updater.phar --no-interaction
sudo -u www -D $nextcloud /usr/local/bin/php ./occ app:update --all
popd