seany123 Posted September 1, 2009 Share Posted September 1, 2009 I really don't know where this goes on this forum... but anyway. with my hosting cpanel i made a Cron job or tab... that basically runs every minute and goes to the following... /home/maf10000/www/index.php but when i get my confirmation email through to say if the cron worked or not i get this message.... /bin/sh: /home/maf10000/www/index.php: Permission denied does anyone know why its not working? Quote Link to comment https://forums.phpfreaks.com/topic/172675-solved-cron-jobs/ Share on other sites More sharing options...
trq Posted September 1, 2009 Share Posted September 1, 2009 Does the script have the execution bit set? eg; chmod'd 744 ? Also, make sure the script has a shebang line... #!/usr/bin/php Quote Link to comment https://forums.phpfreaks.com/topic/172675-solved-cron-jobs/#findComment-910171 Share on other sites More sharing options...
seany123 Posted September 1, 2009 Author Share Posted September 1, 2009 well looking on the cpanel the file index.php has file permissions 0644 what is that shebang thing? and what do i do with it? Quote Link to comment https://forums.phpfreaks.com/topic/172675-solved-cron-jobs/#findComment-910172 Share on other sites More sharing options...
trq Posted September 1, 2009 Share Posted September 1, 2009 644 is non executable, it needs to be at least 744. The shebang line tells the shell what program to use to execute the script. It needs to go on the first line and tells the shell to use php (Linux doesn't car about file extensions). Quote Link to comment https://forums.phpfreaks.com/topic/172675-solved-cron-jobs/#findComment-910173 Share on other sites More sharing options...
seany123 Posted September 1, 2009 Author Share Posted September 1, 2009 okay now im getting this error: /home/maf10000/www/index.php: line 1: ?php: No such file or directory /home/maf10000/www/index.php: line 2: syntax error near unexpected token `"lib.php"' /home/maf10000/www/index.php: line 2: `include("lib.php");' this is the top of my index.php <?php include("lib.php"); define("PAGENAME", "Index"); Quote Link to comment https://forums.phpfreaks.com/topic/172675-solved-cron-jobs/#findComment-910174 Share on other sites More sharing options...
seany123 Posted September 1, 2009 Author Share Posted September 1, 2009 Does anyone know how to fix this??? Quote Link to comment https://forums.phpfreaks.com/topic/172675-solved-cron-jobs/#findComment-910187 Share on other sites More sharing options...
trq Posted September 1, 2009 Share Posted September 1, 2009 Again, you need to add the shebang line at the top of your script. Without it, bash itself tries to execute php which will not work. Quote Link to comment https://forums.phpfreaks.com/topic/172675-solved-cron-jobs/#findComment-910190 Share on other sites More sharing options...
seany123 Posted September 1, 2009 Author Share Posted September 1, 2009 does that go inside the <?php tags? if so then it just seems to work as a comment. and if its outside of the <?php tags then its being displayed on the index.php page as just text. Quote Link to comment https://forums.phpfreaks.com/topic/172675-solved-cron-jobs/#findComment-910196 Share on other sites More sharing options...
trq Posted September 1, 2009 Share Posted September 1, 2009 It goes outside the <?php tags because it has nothing to do with php. As for the shebang displaying... is this when you call the same script via http? Shell scripts are just that, you shouldn't try and execute them via http. Quote Link to comment https://forums.phpfreaks.com/topic/172675-solved-cron-jobs/#findComment-910200 Share on other sites More sharing options...
seany123 Posted September 1, 2009 Author Share Posted September 1, 2009 well this is where im going to have a problem then... index.php as in the name is my index page... (first page) i need the cron to visit that page and allow it to run the included files. Quote Link to comment https://forums.phpfreaks.com/topic/172675-solved-cron-jobs/#findComment-910204 Share on other sites More sharing options...
trq Posted September 1, 2009 Share Posted September 1, 2009 Then you'll need to call the script via http. You can use wget for this. eg; wget http://yoursite.com/index.php Quote Link to comment https://forums.phpfreaks.com/topic/172675-solved-cron-jobs/#findComment-910205 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.