[RESOLVED] Cron Jobs not working NC14.0.3

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 execute by owner.

2 Likes

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.

Hi,
Just a note - Path that you described to Cron.php isn’t the same, but yes, everyone must set they path.

I’ve been having this problem too. I’ve started of with the example docker-compose NC installation that has a dedicated “cron” appliance. Although crond printed a convincing message every minute or so, the web interface displayed a warning that the last cron job was not executed lately enough.

I did a little bit of digging. Turns out that:

  1. Cron modifies the config file with the last run timestamp, so it needs read/write access to the NC filesystem. Currently, the example docker-compose.yml ships with a read-only permission only.
  2. It’s necessary to chmod +x cron.php. I don’t know why. I admit, it’s a bit dubious since the file in question isn’t executed directly but rather interpreted with PHP. However, adding the execute permission has made all the difference for me.

Now, crond still prints a series of log messages every minute or so, but there is more lines and the web interface is not showing the “no cron” warning anymore.

I am having the same issue. What do you do when you’ve installed Nextcloud via Snap and the filesystem (including cron.php) is read-only so you can’t set cron.php to +x?

Use this command:

chmod 744 cron.php