nextcloud cron jobs intergration with systemd

October 30, 2020 - Reading time: 2 minutes

From Nextcloud background jobs. 

In order to get systemd to run the cron job every 5 minutes you need to do the following. Here is my configuration for my nextcloud instance (public)

/etc/systemd/system/nextcloud_autotraining.service

[Unit]
Description=Nextcloud cron.php job

[Service]
User=www-data
ExecStart=/usr/bin/php -f /var/www/autotraining.duckdns.org/cron.php
root@raspberrypi:~# cat /etc/systemd/system/nextcloudcron_autotraining.timer
[Unit]
Description=Run Nextcloud cron.php every 5 minutes

[Timer]
OnBootSec=5min
OnUnitActiveSec=5min
Unit=nextcloudcron_autotraining.service

[Install]
WantedBy=timers.target
root@raspberrypi:~# cat /etc/systemd/system/nextcloudcron_autotraining.service
[Unit]
Description=Nextcloud cron.php job

[Service]
User=www-data
ExecStart=/usr/bin/php -f /var/www/autotraining.duckdns.org/cron.php

Now the nextcloud_autotraining.timer

[Unit]
Description=Nextcloud cron.php job

[Service]
User=www-data
ExecStart=/usr/bin/php -f /var/www/autotraining.duckdns.org/cron.php
root@raspberrypi:~# cat /etc/systemd/system/nextcloudcron_autotraining.timer 
[Unit]
Description=Run Nextcloud cron.php every 5 minutes

[Timer]
OnBootSec=5min
OnUnitActiveSec=5min
Unit=nextcloudcron_autotraining.service

[Install]
WantedBy=timers.target

This now needs to be activated by:

systemctl enable --now nextcloudcron_autotraining.timer

Now as long as your filenames are correct, it should all start and run :)

LazyCoderOZ

I am a Linux guy, been around for 20+ years using Linux as my daily driver.
This is my blog on my discoveries and notes so I don't forget how I have done things :)