- To run a PHP cron job,
www-data
needs to do a crontab job itself, using php -f
as the [user] inside the cronjob line:
*/15 * * * * php -f /var/www/nextcloud/cron.php
(These are Nextcloud instructions. They got it right, don't try to hack this, in my case.)
www-data
must run the cron job itself as a crontab (not /etc/cron.d
, et al)
Normally, this is set up from the terminal:
Running as root
in this example...
crontab -u www-data -e
...add the cronjob string (above).
crontab -u www-data -l
...and it should match.
But, I need this done as a script, not crontab -e
in the terminal.
- Do this via shellscript (danger?):
crontab jobs are in: /var/spool/cron/crontabs/USER
with permissions: -rw------- ... www-data crontab
The script that worked:
Running as root
in this example...
echo "*/15 * * * * php -f /var/www/nextcloud/cron.php" >> /var/spool/cron/crontabs/www-data
chown www-data:crontab /var/spool/cron/crontabs/www-data
chmod 600 /var/spool/cron/crontabs/www-data
Oh, Happy Day!