I am trying to execute a PHP script using crontab but it doesn't seem to work. I am running AWS EC2 Linux and here is the PHP script:
FOREACH (GLOB("*.jpg") AS $filename) {
ECHO "$filename size " . FILESIZE($filename) . "\n";
UNLINK($filename);
}
FOREACH (GLOB("*.jpeg") AS $filename) {
ECHO "$filename size " . FILESIZE($filename) . "\n";
UNLINK($filename);
}
FOREACH (GLOB("*.gif") AS $filename) {
ECHO "$filename size " . FILESIZE($filename) . "\n";
UNLINK($filename);
}
FOREACH (GLOB("*.png") AS $filename) {
ECHO "$filename size " . FILESIZE($filename) . "\n";
UNLINK($filename);
}
When I execute this script manually from a browser, it works normally. But it doesn't work using crontab
Here is my cron command:
00 * * * * php /var/www/html/*****/*****/delete.php
And here is the log:
Nov 28 02:12:01 ip-##-##-##-## CROND[#####]: (root) CMD (/usr/bin/php /var/www/html/*****/*****/delete.php)
What am I possibly doing wrong?
00 * * * * cd <some-directory> && php /var/www/html/*****/*****/delete.php- Ryan Jones