I have a PHP file that is suppose to send one email per day scheduled by crontab. Here is my crontab:
45 23 * * * php /var/www/html/linus/class/runnable/dailyStaffReport.php
I noticed that it's not working, that is, the email is not being sent. So I tried the following:
00 11 * * * php /var/www/html/linus/class/runnable/dailyStaffReport.php >> /var/log/crontab.linus.log 2>&1
Note: the time schedule here is not important, I'm constantly changing it for the testing purpose
That did not work. The file
crontab.linus.log was not created.
While checking the
/var/log/cron file, I noticed that my cron is executed
Feb 25 11:22:01 shoutcast01 CROND: (apache) CMD (php /var/www/html/linus/class/runnable/dailyStaffReport.php >> /var/log/crontab.linus.log 2>&1)
And lastly, if I manually execute
php /var/www/html/linus/class/runnable/dailyStaffReport.php I get the email right away in my inbox. I even wrote some
echoes in the PHP script in the hopes to try and see if somewhere along the line the script fails.
[root@shoutcast01 ~]# php /var/www/html/linus/class/runnable/dailyStaffReport.php LOADING STAFF USERS... COMPUTING STAFF WORK TIME... BUILDING CHART... SAVING CHART... WRITING DOWN THE CHART... SENDING THE EMAIL... 1 DONE.
On a simular matter, I have another file that is scheduled to send emails every 2 minutes and it works perfectly.
[root@shoutcast01 ~]# crontab -u apache -l 22 11 * * * php /var/www/html/linus/class/runnable/dailyStaffReport.php >> /var/log/crontab.linus.log 2>&1 */2 * * * * php /var/www/html/linus/class/runnable/dispatchEmail.php
To sum up
- The email gets delivered if I execute the script manually in the terminal.
- the email does not gets delivered, but cron log tells me the script was executed.
- I'm unable to log anything with
>> /var/log/crontab.linus.log 2>&1
Any tips on what I can do to try and solve this problem?