[RESOLVED] Cron Jobs not working NC14.0.3

Hello guys,

good day and hoping everything is going well.

i recently did a fresh install of NC14.0.3 after a failed update from 13.

i tried configuring the cron jobs following this link but being unable to make them to run.

can you please provide any advise?

REgards!!

Hi guys, anyone can provide any input?

Regards!!

Hi,

Unfortunately you didn’t provide much information.

  • what is your OS?
  • what is your web server user?
  • what exactly did you configure?
  • what exactly doesn’t work?
  • how did you try to solve the problem already?

apologies for the lack of info on my post.

what is your OS? Raspbian on Raspberry Pi 3 B+
what is your web server user? www-data
what exactly did you configure? created files nextcloudcron.service and nextcloudcron.timer based on the admin guide for NC14
what exactly doesn’t work? Cron jobs not running
how did you try to solve the problem already? I followed the guide and still not running every 15 minutes.

Regards!!

any ideas why the cron jobs wont run after being configured?

Regards!

I was actually hoping you provide some additional information as well and not only answers to my questions.

Anyway, more questions:
Did you create the cron job for the www-data user?
Which command did you use to open the cron editor?
Which command line did you enter as cron job?
Did you try to run that command line manually (as user www-data) and did it finish successfully?
Are there any error messages in the journal/ system logs regarding the cron execution?
Do other cron jobs run successfully or is cron not implemented correctly?

Update
Sorry, I assumed cron job, but you configured a service. Please check if the service is running and triggered successfully then. Logs are required nonetheless. We need the information what exactly fails.

Kind regards

hi Schmu, what did was follow the Admin guide on the cron jobs and created them as stated there.

i did this same steps for NC13 and those were working normally.

i just tried the following:
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start ‘nextcloudcron.timer’.
Multiple identities can be used for authentication:

  1. , (pi)
  2. root
    Choose identity to authenticate as (1-2): 2
    Password:
    polkit-agent-helper-1: pam_authenticate failed: Authentication failure
    ==== AUTHENTICATION FAILED ===
    Failed to start nextcloudcron.timer: Access denied
    See system logs and ‘systemctl status nextcloudcron.timer’ for details.
    root@rpi3-cloud:/home/pi# sudo -u www-data systemctl enable nextcloudcron.timer
    ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ===
    Authentication is required to manage system service or unit files.
    Multiple identities can be used for authentication:
  3. , (pi)
  4. root
    Choose identity to authenticate as (1-2): 2
    Password:
    polkit-agent-helper-1: pam_authenticate failed: Authentication failure
    ==== AUTHENTICATION FAILED ===
    Failed to enable unit: Access denied
    root@rpi3-cloud:/home/pi#

also i did this:
root@rpi3-cloud:/home/pi# sudo -u www-data php -f /var/www/html/nextcloud/cron.php
root@rpi3-cloud:/home/pi# sudo -u www-data php -l /var/www/html/nextcloud/cron.php
No syntax errors detected in /var/www/html/nextcloud/cron.php
root@rpi3-cloud:/home/pi#

Also, after running systemctl start nextcloudcron.timer and systemctl enable nextcloudcron.timer as root i dont get any error messages

i hope this helps a bit… :slight_smile:

The messages there indicate that the password is probably wrong. The authentication failed.

I believe you need to enable and start the service as root user.

i did run them as root and got no error messages.

i went into the Basic Settings on the web server and the last time the cron job ran was over 17 minutes.

I actually don’t know how to debug a service. Especially if you say there are no messages in the logs regarding this service.

Does
systemctl status nextcloudcron.timer
output something useful?

this is what i get after running systemctl status nextcloudcron.timer
root@rpi3-cloud:/home/pi# systemctl status nextcloudcron.timer
● nextcloudcron.timer - Run Nextcloud cron.php every 15 minutes
Loaded: loaded (/etc/systemd/system/nextcloudcron.timer; enabled; vendor preset: enabled)
Active: active (waiting) since Sat 2018-10-20 23:44:26 CDT; 1 day 11h ago

Oct 20 23:44:26 rpi3-cloud systemd[1]: Started Run Nextcloud cron.php every 15 minutes.

but i dont see it running every 15 minutes. currently its been more than 30 minutes and not running

Could you post your service files you configured? Maybe there is a little typo or something. Just to be sure.

this is the commands within nextcloudcron.service

[Unit]
Description=Nextcloud cron.php job

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

[Install]
WantedBy=basic.target

this are the commands within nextcloudcron.timer

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

[Timer]
OnBootSec=5min
OnUnitActiveSec=15min
Unit=nextcloudcron.service

[Install]
WantedBy=timers.target

both files are under /etc/systemd/system/

Why do you want to make it a service?

Just put it in crontab as everyone else. :slight_smile:

how would i achieve that?

I have same issue with cron.php job. So I worked out that by default nextcloud installation ships with wrong owner permissions for cron.php It must have [X] execute by owner.

https://docs.nextcloud.com/server/11/admin_manual/configuration_server/background_jobs_configuration.html#cron

looks like after adding the [x] to the cron.php it started running every 15 minutes.

kudos and thanks for the tip… :smiley:

this got resolved by adding [x] to the permissions of the cron.php:

root@server:/home/pi# ls -l /var/www/html/nextcloud/cron.php
-rwxr–r-- 1 www-data www-data 4979 Oct 12 01:47 /var/www/html/nextcloud/cron.php

Also, by adding the following:
run sudo crontab -u www-data -e

add the following lines
# crontab -u www-data -e
*/15 * * * * php -f /var/www/nextcloud/cron.php

after, perform a reboot.

Thanks for everyone that chimed in on getting this fixed.

Regards!!

1 Like

That sounds strange. At least with NC13 there’s no need for cron.php to be executable. Php engine executes it (php -f). Is it possible that your php command is not found when crontab executes it?

Did you try /path/to/php -f instead of just php -f?
Or call php-cli instead of php.

There should not be anything executable which are not really meant to be executable.