gevans Posted October 9, 2009 Share Posted October 9, 2009 I've setup a cron job using my admin panel at heart internet. Everytime it runs I get an email of the results. When I call this file directly it runs fine. When it runs via the cron I get the following errors; [pre]X-Powered-By: PHP/5.2.10 Content-type: text/html /home/sites/example.co.uk/public_html/blog/wp-content/plugins/gareth_twitter/cron.php: line 2: ?php: No such file or directory /home/sites/example.co.uk/public_html/blog/wp-content/plugins/gareth_twitter/cron.php: line 3: =: command not found /home/sites/example.co.uk/public_html/blog/wp-content/plugins/gareth_twitter/cron.php: line 4: syntax error near unexpected token `'/home/sites/example.co.uk/public_html/blog/wp-content/plugins/gareth_twitter/'.$filename' /home/sites/example.co.uk/public_html/blog/wp-content/plugins/gareth_twitter/cron.php: line 4: `include('/home/sites/example.co.uk/public_html/blog/wp-content/plugins/gareth_twitter/'.$filename);'[/pre] 'example' is replaced with my domain. First three lines of the file; /usr/bin/php5 <?php $filename = 'tweets.php'; The first error is on line to where I have the php oppening tags '<?php'. They're offering me now support on this as it's a 'coding' problem. Any ideas what might be going on? Cheers, Gareth EDIT: The first line of the file is a line they say to add; If the scheduled program includes code from a scripting language, the path for the interpreter must be specified before the script. For example, /usr/bin/perl (Perl), /usr/bin/php (PHP 4) or /usr/bin/php5 (PHP 5) Quote Link to comment https://forums.phpfreaks.com/topic/177086-cron-jobs-at-heart-internet/ Share on other sites More sharing options...
Daniel0 Posted October 9, 2009 Share Posted October 9, 2009 It has to be: #!/usr/bin/php5 (assuming that is the path to your PHP binary) This is called a shebang. Google it Quote Link to comment https://forums.phpfreaks.com/topic/177086-cron-jobs-at-heart-internet/#findComment-933689 Share on other sites More sharing options...
gevans Posted October 9, 2009 Author Share Posted October 9, 2009 Hmmmmm, they do mention a shebang on the next line of their info; If the scheduled program includes code from a scripting language, the path for the interpreter must be specified before the script. For example, /usr/bin/perl (Perl), /usr/bin/php (PHP 4) or /usr/bin/php5 (PHP 5) If the script being run is adapted from a CGI script, ensure the first line of the script is a 'shebang' line containing the correct interpreter path - as above - (for example #!/usr/bin/perl). I'm trying this as we speak (waiting for an email).... Quote Link to comment https://forums.phpfreaks.com/topic/177086-cron-jobs-at-heart-internet/#findComment-933692 Share on other sites More sharing options...
Daniel0 Posted October 9, 2009 Share Posted October 9, 2009 How are you calling it "directly"? Like post the command or whatever. Quote Link to comment https://forums.phpfreaks.com/topic/177086-cron-jobs-at-heart-internet/#findComment-933698 Share on other sites More sharing options...
gevans Posted October 9, 2009 Author Share Posted October 9, 2009 Sorry, by directly I meant. via a browser while the first line was taken out.... not really a sure thing test... It may be working now, no errors, but I have to change some flat files to cheque that its working, so we're getting close... Quote Link to comment https://forums.phpfreaks.com/topic/177086-cron-jobs-at-heart-internet/#findComment-933705 Share on other sites More sharing options...
gevans Posted October 9, 2009 Author Share Posted October 9, 2009 UPDATE: All working, thanks to the shebang. Cheers Daniel. Funny how their support team didn't pick up on that. Quote Link to comment https://forums.phpfreaks.com/topic/177086-cron-jobs-at-heart-internet/#findComment-933707 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.