Change cron job interval from 15 minutes to 50 minutes

Hi,

I’,m trying to reduce the cron job background interval. The Nextcloud instance is used as an image storage and private calendar. Hence, I don not need it to wake the HDD every 15 minutes for background jobs.

specs:

NextCloudPi version v1.19.1
NextCloudPi image NextCloudPi_08-02-19
distribution Debian Buster with Armbian Linux \l
Nextcloud version 17.0.1.1

I’ve followed the documentation:

https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/background_jobs_configuration.html#systemd

I’ve adapted nextcloudcron.time:

[Unit]
Description=Run Nextcloud cron.php every 50 minutes

[Timer]
OnBootSec=50min
OnUnitActiveSec=50min
Unit=nextcloudcron.service

[Install]
WantedBy=timers.target

and nextcloudcron.service

[Unit]
Description=Nextcloud cron.php job

[Service]
User=eric
ExecStart=/usr/bin/php -f /var/www/nextcloud/cron.php

[Install]
WantedBy=basic.target

accordingly. My last try was to increase interval to 50 minutes.

Following the documentation I’ve enabled the service the terminal com:

eric@nextcloudpi:~$ systemctl enable --now nextcloudcron.timer
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ===
Authentication is required to manage system service or unit files.
Authenticating as: ,,, (eric)
Password: 
==== AUTHENTICATION COMPLETE ===
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: ,,, (eric)
Password: 
==== AUTHENTICATION COMPLETE ===
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'nextcloudcron.timer'.
Authenticating as: ,,, (eric)
Password: 
==== AUTHENTICATION COMPLETE ===

Even after reboot the cron job interval continues to be 15 minute. Any advice would be really appreciated. I’d aim to extend the interval to 2 hours or so…

Best regards,

Eric

What is set in your crontab?

sudo -u www-data crontab -l

Alright, thanks! A very good point:

*/15 * * * * php -f /var/www/nextcloud/cron.php

I just need to change that? or do I have to follow the documentation as well?
Thanks again!

Basically they are 2 different approaches.

  • One is via Cron job that you have had configured and it’s running each 15 min.
    Simply set it to */50 * * * * php -f /var/www/nextcloud/cron.php to execute cron job every 50 min, or to e.g. 10 * * * * php -f /var/www/nextcloud/cron.php to execute it once per hour at 10 minutes, e.g. 11:10, 12:10 etc. --> Read more about cron config.
    Command to edit crontab is sudo -u www-data crontab -e

  • Another one is via System Daemon as you did and linked Doku above.

You have to decide witch one you would like to use:

  1. ether comment line in a crontab and live daemon:
#*/15 * * * * php -f /var/www/nextcloud/cron.php
  1. or edit crontab as you wish and disable your newly created daemon via:
systemctl disable --now nextcloudcron.timer

P.S.: Personally I use cron, it is easy way to configure periodically jobs.

1 Like

Thanks so much for the clarification and thanks so much for the detailed desciption on how to approach my issue.
Have a good day!

1 Like