Cron job not running correctly

Hi all,

I’m having some difficulty getting a cronjob to run correctly. The cron option is selected in the options below:


Last cron job execution: 7 days ago. Something seems wrong.
Execute one task with each page loaded
cron.php is registered at a webcron service to call cron.php every 15 minutes over http.
Use system’s cron service to call the cron.php file every 15 minutes.

I have the following in my user crontab:
15 * * * * sudo -u www-data /usr/bin/php -f /var/www/ system:cron

Which runs as expected from the command line and resets the timers etc.

Can someone please tell me:
a) whether the command is correct?
b) which crontab it should be run from?
c) what I might do to make owncloud recognize the fact that the cronjob has run?


Operating system: Ubuntu 18.04
Web server: apache
Database: mysql
PHP version: PHP 7.2.24-0ubuntu0.18.04.4
ownCloud version: ownCloud 10.4.1 (stable)

This is what my crontab looks like for use www-data


i’m not sure if it makes much sense to add the crontab entry like this for the root user and then use sudo to run it as www-data. Maybe this is already the problem, have you tried to add this entry without the sudo call to the www-data user?

I also think that there could be logging done into the syslog where you could see why the cron run doesn’t happen.

The “Desktop” category is looking wrong to me as well (not sure why this category was chosen for a Server configuration problem? :frowning_face:), maybe you could edit your post and put the topic into the correct "Server category?

1 Like

You should do it this way

1 Like

Regarding cron jobs there are a few things to know/do:

  • There has to be a line break at the end of your cron line
  • Due to this, never ever edit your cron file on Windows, they are using line breaks incompatible with Linux
  • Many distributions configure cron to send an email to the root user if there is output on stderr
  • If you don’t have an email configured for root you can redirect your stdout and stderr to a logfile by appending the following: 2&>1 >> /path/to/folder/writable/for/apache-user/cron.log
  • The apache user is called www-data on Debian/Ubuntu, apache on CentOS/RHEL
  • Cron jobs run as sh and not as bash usually
  • To get an identical environment run the command env in a cronjob and write its output to a file, then source that file. Afterwards try rerunning the cron, now you should definitely see the error.
1 Like