My server is running on Ubuntu 14.04 and nginx. My problem concerns Cron, I'd like to start it (crontab) using a file - cron.txt, its contents:
* * * * * /usr/bin/php /var/www/html/test.php >> /var/log/cron.log
If I run it using the command: crontab /var/www/html/cron.txt
, it works perfectly, script test.php is being executed. But, when I do the same using a PHP script (executing via browser): exec('crontab /var/www/html/cron.txt');
, it doesn't work.
Checking current cronjob by command: crontab -l -u www-data
, the line from the file appears, but Cron does not do its job. Maybe it's related to some permission issues? Because it only works by executing as a root. Is there a way to force Cron to do www-data's tasks as well?