Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am running a PHP script which inserts lines in a database every minute, using a cron job.

My provider says:

An email will be sent to this address ONLY if your cron produces output.
If no output is generated, then no email will be sent.

I am only issuing echo statements in my PHP when there is a query error. But I don't have errors, and I see the lines appearing in my DB.

Yet, I still get emails with (nearly) empty content even if I don't have errors:

Content-type: text/html

How can I prevent this? What is considered as output when running a PHP script cron job?

UPDATE

In order to get rid of the header, see: http://stackoverflow.com/questions/10723546/how-to-get-rid-of-content-type-text-html-in-php-script-output

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Do you have any calls to header in the code? Any whitespace outside of <?php ... ?> blocks? To answer your question 'output' is anything that would be sent to the browser in non-CLI operation, like that HTTP header you're seeing.

share|improve this answer
    
No call to header, but what do you mean by white spaces? There are some white spaces between my PHP instructions, but I don't echo or print any... –  JVerstry May 23 '12 at 15:28
    
If you have something like this: <?php dosomestuff(); ?> <?php dosomethingelse(); ?> the spaces between ?> and <?php will be sent as output. –  xofer May 23 '12 at 15:31
    
No, I don't. I only have one <?php ... ?>. I think I need to find how to remove that header... –  JVerstry May 23 '12 at 15:32
    
Try removing the ?> at the end of the file. –  xofer May 23 '12 at 15:33
    
Just did, but it does not solve the issue –  JVerstry May 23 '12 at 15:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.