Www-data cron - occ system:cron

Hello all.
I have ownclud well running but when I try to put in cron the occ system:cron this is not executed.
I have followed the tutorial and the syntax is looks correct:

sudo crontab -u www-data -e
*/15 * * * *  /usr/bin/php -f /var/www/owncloud/occ system:cron

the path to php and to occ is correct.

If I tun the command manually:

sudo -u www-data ./occ system:cron

this works corectly.

But in cron this does not work.

Why ?

Any errors? Is the cron service running?

This is what I get when I put the job in www-data cron:

root@debian:~# systemctl status cron
● cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-05-04 08:32:00 CEST; 2h 29min ago
       Docs: man:cron(8)
   Main PID: 512 (cron)
        CPU: 2min 42.327s
     CGroup: /system.slice/cron.service
             └─512 /usr/sbin/cron -f

May 04 10:30:01 debian CRON[5790]: Authentication failure
May 04 10:30:01 debian CRON[5791]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
May 04 10:30:01 debian CRON[5792]: (root) CMD (/usr/sbin/omv-mkrrdgraph >/dev/null 2>&1)
May 04 10:39:01 debian CRON[6023]: (root) CMD (  [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
May 04 10:45:01 debian cron[6193]: Authentication failure
May 04 10:45:01 debian CRON[6193]: Authentication failure
May 04 10:45:01 debian CRON[6194]: (root) CMD (/usr/sbin/omv-mkrrdgraph >/dev/null 2>&1)
May 04 11:00:01 debian cron[6520]: Authentication failure
May 04 11:00:01 debian CRON[6520]: Authentication failure
May 04 11:00:01 debian CRON[6521]: (root) CMD (/usr/sbin/omv-mkrrdgraph >/dev/null 2>&1)

If I remove (comment) the job in the www-data cron the status is OK:

root@debian:~# systemctl status cron
● cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-05-04 11:03:44 CEST; 10s ago
       Docs: man:cron(8)
   Main PID: 6722 (cron)
        CPU: 34ms
     CGroup: /system.slice/cron.service
             └─6722 /usr/sbin/cron -f

May 04 11:03:44 debian systemd[1]: cron.service: Consumed 2min 42.329s CPU time.
May 04 11:03:44 debian systemd[1]: Started Regular background program processing daemon.
May 04 11:03:44 debian cron[6722]: (CRON) INFO (pidfile fd = 3)
May 04 11:03:44 debian cron[6722]: (CRON) INFO (Skipping @reboot jobs -- not system startup)

Maybe try using root’s crontab instead?

From wheel user :
sudo crontab -e

From root:
crontab -e

Then edit the cron:
*/15 * * * * su www-data -c "/usr/bin/php -f /var/www/owncloud/occ system:cron"

Start the cron if it hasn’t already:
systemctl start cron

cron is up and running, and the command line appears to be correct.
I’d rather investigate, why cron-jobs from www-data are failing. This is working on many other systems, but not here.

Yes. This is the workaround I have done and it works.
Furthermore I needed to correct the path because of php7.4…

*/15 * * * * su www-data -c "/usr/bin/php7.4 -f /var/www/owncloud/occ system:cron"

I then investigated the cron for www-data and it seems this is not within the allowed in the PAM.
Finally i do not like to mess up the PAM security so I will remain with this workarond.

Thanks for your help.

1 Like