Sync / Share Google Calendar & Nextcloud Calendar

I just add this hack to do if you sync a google calendar on your Nextcloud Calendar.

The refresh rate of a calendar subscription in Nextcloud is once every week by default.

https://docs.nextcloud.com/server/19/user_manual/pim/calendar.html

Subscriptions are refreshed every week by default. Your admin may have changed this setting.

Change the refresh rate:

  • Connect with a terminal in ‘root’ to the Nextcloud instance.
  • Position yourself at the root of the Nextcloud site.
    cd /var/www/nextcloud.example.com/www/ # For example
  • Get the owner of the ‘config.php’ file.
ls -l config/config.php
.rw-r----- nextcloud nextcloud 1.5 KB Wed May 25 10:17:35 2022 config/config.php
  • Change the value of the ‘calendarSubscriptionRefreshRate’ option of the Nextcloud calendar app to 5 minutes.
sudo -u nextcloud php8.0 occ config:app:set dav calendarSubscriptionRefreshRate --value "PT5M"
# Résultat :
# Config value calendarSubscriptionRefreshRate for app dav set to PT5M
  • Use the user who owns the config file.php with the sudo command. Use the php binary corresponding to the Nextcloud version.
  • Check the consideration.
sudo -u nextcloud php8.0 occ config:list | grep -i calendar
# Résultat :
#        "calendar": {
#            "calendarSubscriptionRefreshRate": "PT5M",

Crontab

  • Edit the crontab of the user who owns the config file.php seen above.
sudo -u nextcloud crontab -e
  • Add a task every 5 minutes running the php script located at the root of the Nextcloud site.
*/5 * * * * php8.0 -f /var/www/nextcloud.example.com/www/cron.php
  • Use the php binary corresponding to the Nextcloud version.
  • Log in as ‘admin’ on the Nextcloud web interface. Then go to Settings.
  • In the Administration section at the bottom left, go to Basic Settings.
  • Ensure that Background Tasks are configured with ‘Cron’.

Sources

https://www.aukfood.fr/nextcloud-ajouter-un-calendrier-google-prive-sans-credentials/
Using the Calendar app — Nextcloud latest User Manual latest documentation
Calendar / CalDAV — Nextcloud latest Administration Manual latest documentation
PHP: DateInterval::__construct - Manual