Reputation: 381
I have a PHP script that sends out a bi-weekly reminder to subscribers. Each time it sends out the email it also sends out an email that comes in from "Cron Daemon." When I first wrote the script, it didn't send this email, but now it does. I have a few questions about this.
This is what the email says:
Set-Cookie: PHPSESSID=((random letters and numbers here)); path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-type: text/html
Upvotes: 0
Views: 762
Reputation: 12537
Cron reads the stdout/stderr of the command that gets executed, if something is written then cron sends an E-Mail.
I guess the php-executable is compiled as "cgi" or "fcgi" so it emits those headers by default.
To solve this you have apparently three possible solutions:
> /dev/null 2>&1
to your cron command).MAILTO=""
(see this page).Upvotes: 1
Reputation: 39560
My guess is your PHP script is rendering something to the output. If anything gets rendered at all, cron forwards that to the default administrator email.
There's two solutions to this:
1) Fix your PHP script to not output anything at all. This is sometimes harder than it would seem, especially for non-trivial scripts.
2) Prevent the cron script from ever having an output. The drawback to this method is you won't get a notice when the script fails, either. To stop the output, use something like this:
#Before
* * * * * php /path/to/script
#After
* * * * * php /path/to/script > /dev/null 2>&1
Upvotes: 0