PHP Error Line 1: `<? Php?> '

I am trying to set up a very simple cron job on a website. I have cron.php that runs every minute. Right now, for testing purposes, cron.php is just this:

<?php ?>

And now, every minute, I get a cron email with these errors:

//home/user/public_html/mysite/cron.php: line 1: syntax error near unexpected token newline

//home/user/public_html/mysite/cron.php: line 1: <?php ?>

Does this server really have a hard time accessing PHP from the command line or is there some other problem that I don't see?

In addition, I had similar strange errors when trying to add things like echo "test";or even justphpinfo();

+5
source share
4 answers

You don't have a shebang line, so it is trying to execute the script using the default shell.

#!/usr/bin/php ( PHP) script.

+9

cron cmd /path/to/executable.php//path/to/file.php

, , , , php

+1

"#!/usr/bin/env php" .php .  env php . , .

+1

, , , -. cron, cron, - , :

wget http://www.mywebsite.com/xml/Cron.php > /dev/null

webiste script.

,

0

All Articles