run cronjobs and send to email problems
I want to create cronjobs that runs 开发者_Python百科every 10 min < time now
and mail me a email with the follow txt.
"deleted orders"
my code looks like this.
MAILTO=”my_email@mail.com”
*/10 * * * * /var/www/php-sites/dlf/cron_jobs.php
I have checked my mails the last 30 min.. and still havent receive any mails. am i doing it wrong ?
First of all, as I remember php scripts should be executed this way (example for Ubuntu path, not sure about other distros):
/usr/bin/php-cgi /var/www/php-sites/dlf/cron_jobs.php
Also you can save the job output into the file to see the exact reasons of failures, for your job it can look like:
*/10 * * * * /usr/bin/php-cgi /var/www/php-sites/dlf/cron_jobs.php > /tmp/cron.out 2>&1
Check the cron.out contents.
Hope this helps.
EDIT
I did small test and usual Shell way seems to work too. I've created the script phptest.sh (+x) with contents:
#!/usr/bin/php-cgi
echo "It works this way!";
And it seems to work, except one thing. It throws the headers in the stdout, like this:
***@***:~$ ./phptest.sh
X-Powered-By: PHP/5.2.10-2ubuntu6.3
Content-type: text/html
echo "It works this way!";
But I suppose we can get rid of them somehow, if they are a problem.
The only advantage of this is shorter path :)
精彩评论