I log into my AWS server as ec2-user, but I try to have everything run as root, so I manage my crontab with the sudo crontab -e command. This is what is in it:
* * * * * php /var/www/html/a*****/cron/cron.php
* * * * * php /var/www/html/d*****/cron/cron.php
* * * * * /usr/bin/php -f /var/www/html/k*****/cron/cron.php
* * * * * php /var/www/html/l*****/cron/cron.php
The /var/www/html/k*****/cron/cron.php script looks like the following:
<?php
include_once('../functions.php');
date_default_timezone_set("UTC");
// ==============================================
$content = file_get_contents("output.txt");
file_put_contents("output.txt", date('j M Y \a\t g:ia').
"\n\n---------------------\n".$content);
// ==============================================
performScheduledJobs();
The other cron.php files in the sudo crontab -e view all look identical, except without the bit between the // ===== marks.
Since these scripts are supposed to run every minute (per the sudo crontab -e settings, with the five spaced asterisk marks * * * * *), I would expect the output.txt to have the current timestamp (in UTC) being printed every minute. Instead, it only contains the (UTC) timestamp of every time the script is run manually using the following command:
sudo php cron.php
That command (from within the /var/www/html/k*****/cron/ directory, of course) works 100% successfully.
Of course, my instinct is that the cron.php file isn't even being attempted to be run, but when I sudo vi /var/log/cron I see the following:
Mar 27 21:51:01 ip-172-***-***-184 CROND[32032]: (root) CMD (php /var/www/html/a*****/cron/cron.php)
Mar 27 21:51:01 ip-172-***-***-184 CROND[32033]: (root) CMD (php /var/www/html/d*****/cron/cron.php)
Mar 27 21:51:01 ip-172-***-***-184 CROND[32035]: (root) CMD (/usr/bin/php -f /var/www/html/k*****/cron/cron.php)
Mar 27 21:51:01 ip-172-***-***-184 CROND[32034]: (root) CMD (php /var/www/html/l*****/cron/cron.php)
As I said running the sudo php cron.php command works, so whatever is wrong is likely with my crontab configuration.
Anyone have and ideas?