I'm attempting to setup a very simple cron job on a web host. I have cron.php set to run every minute. Right now, for testing purposes, cron.php is simply this:
<?php ?>
And now, every minute, I'm receiving the 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 ?>
Is this server having a hard time accessing PHP from the command line or is there some other issue I'm not seeing?
Also, I've gotten similarly weird errors when trying to add in things like echo "test";
or even just phpinfo();
You have no shebang line, so it is trying to execute the script using the default shell.
Add #!/usr/bin/php
(or wherever PHP is) to the top of the script.
for cron jobs you normally have to specify the executable in the cmd line /path/to/executable.php //path/to/file.php
the environment is probably returning the token error because it doesnt know what php is or what to do with it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With