Reputation: 821
$_SERVER['DOCUMENT_ROOT']/file.php: line 1: ?php: No such file or directory
$_SERVER['DOCUMENT_ROOT']/file.php: line 2: syntax error near unexpected token `0'
$_SERVER['DOCUMENT_ROOT']/file.php: line 2: `set_time_limit(0);'
the above error, i got while run cron,
can anyone help me... Thanks in Advance..
Regards, Vinoth S
Upvotes: 5
Views: 9960
Reputation: 508
Use this line of code for the cron set up. Also in your cpanel set an email id where you can get an email whenever cron execute successfully so that you know that you have successfully set a cron job.
wget -O - http://YOURSITE/cron.php?cron_key=abcd
Upvotes: 0
Reputation: 821
Thank u for all ur comments... its very useful to me... But i try the all the way, But my hosting domain ll not support, thats y i tried,
php -q /path/to/the/script.php
like that, its working fine,My cron now working fine... Thank u all...
Regards, Vinoth S
Upvotes: 4
Reputation: 85778
Adding #!/usr/bin/php5
to the top of your script as in goreSplatter's answer perfect for scripts your are writing to run on a single machine. If you want to ensure that the script will work on other machines that might have PHP installed elsewhere (such as /usr/local/bin/php5
), then you can make use of the env
command to search for php under the current user's $PATH:
#!/usr/bin/env php
Upvotes: 1
Reputation: 34632
You're directly invoking the .php file. The shell looks for a shebang and finds <?php
which is not a valid command line interpreter.
You'll have to prefix your script with something like:
#!/usr/bin/php5
Or in your crontab:
* * * * * /usr/bin/php5 /path/to/the/script.php
Upvotes: 8