I need to get this to run in a cron file in /etc/cron.d/
:
*/15 * * * * php -f /var/www/nextcloud/cron.php
...but, my scripts don't run. It's permissions are set to 644 and I need to create it with a Shell/BASH script. I'm using:
echo "*/15 * * * * php -f /var/www/nextcloud/cron.php" > /etc/cron.d/nccron
What am I doing wrong?
There is an much easier way (must be done as
root
user)echo '*/15 * * * * www-data php -f /var/www/nextcloud/cron.php' > /etc/cron.d/wwwcron
I'd use SINGLE quotes not DOUBLE quotes to prevent any possibility of expansion of the '*' metasymbol.
www-data
needs to do a crontab job itself, usingphp -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.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...Oh, Happy Day!