1

I have a php script in a cron job:

0 * * * * php -q /path/to/script.php

I use the -q switch to suppress any output other than what the script itself produces. The script will only output content when there is something to see.

cron will send an email if there is output to stdout, which is exactly what I want.

However, it appears that php -q will always output a carriage return. This is enough output to trigger crons email notification.

# php -q script.php > test.txt
# ls -la test.txt
-rw-r--r-- 1 test test 1 Oct 12 22:41 test.txt

Is there a way to get -q mean "really output nothing"?

Paul
  • 538
  • 6
  • 23
  • 2
    You have probably that carriage return inside the /path/to/script.php file, maybe out of the `` tags. – Nelson Oct 12 '13 at 11:50
  • Damn, you were right, a trailing return. Is this a dupe? If not, please add this as an answer. – Paul Oct 12 '13 at 12:00

1 Answers1

2

You have probably that carriage return inside the /path/to/script.php file, most probably out of the <?php ... ?> tags.

Nelson
  • 49,283
  • 8
  • 68
  • 81