Cron And Php Files

admin

Administrator
Staff member
Hi <br /><br />I have searched the forums exstensively and tried all the alternatatives offered on cron tab and running a script ! I am trying to run a php file that does maintanence for my ad server ! I used to be in a shared enviroment and it worked fine ! I have since moved to a dedicated server to no joy ! <br /><br />Is there something i need to activate on the WHM panel to allow cron to run on the server or am i missing something ? The script is related to php adserver maintanence !<br /><br />I have tried <br /><br />GET <a href="http://www.XXXXXXX/file.php" target="_blank">http://www.XXXXXXX/file.php</a> to no avail <br /><br />Tried it with a path to the file <br /><br />I am way confused !!!!<br /><br />Any help appreciated !<!--content-->
There are many ways to do it, I use:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->wget -q -O - http://example.com/file.php<!--c2--></div><!--ec2--><br /><br />HTH<!--content-->
Or<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->php -q /home/cpanelname/public_html/path-to-php-file<!--c2--></div><!--ec2--><!--content-->
Thanks for the replies !<br /><br />okay - i tried both ! Neither worked ?<br /><br /> I have checked the permission on the file - 755 <br /><br />I have doubled checked the file path<br /><br />Any further suggestions ?<!--content-->
Welcome to the forums, stix! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/thumbup1.gif" style="vertical-align:middle" emoid=":thumbup1:" border="0" alt="thumbup1.gif" /> <br /><br />How did you set up the time for the cron job to run?<!--content-->
<!--QuoteBegin-TCH-David+Jun 30 2005, 09:15 AM--><div class='quotetop'>QUOTE(TCH-David @ Jun 30 2005, 09:15 AM)</div><div class='quotemain'><!--QuoteEBegin-->Welcome to the forums, stix!  <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/thumbup1.gif" style="vertical-align:middle" emoid=":thumbup1:" border="0" alt="thumbup1.gif" /> <br /><br />How did you set up the time for the cron job to run?<br /><div align="right"><a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=137766"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br /><br /><br />Thanks David !<br /><br />I set the time to run every minute mainly just to check i could get it working ! I was plannning to set it back to once an hour as pre the requirements of the software !<br /><br />i tried in both both standard and advanced !<!--content-->
I use the following and it works.<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->/usr/bin/php -q /home/cpanelname/public_html/path-to-php-file<!--c2--></div><!--ec2--><br /><br />Note that I added /usr/bin to the code, not that it should matter though. And replace <b>cpanelname</b> with your actual login name for cpanel.<br /><br />Have you checked your error log file?<!--content-->
<!--QuoteBegin-TCH-Bruce+Jun 30 2005, 09:47 AM--><div class='quotetop'>QUOTE(TCH-Bruce @ Jun 30 2005, 09:47 AM)</div><div class='quotemain'><!--QuoteEBegin-->I use the following and it works.<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->/usr/bin/php -q /home/cpanelname/public_html/path-to-php-file<!--c2--></div><!--ec2--><br /><br />Note that I added /usr/bin to the code, not that it should matter though.  And replace <b>cpanelname</b> with your actual login name for cpanel.<br /><br />Have you checked your error log file?<br /><div align="right"><a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=137772"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br /> <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> Still no joy .....<br /><br /><br />I looked in the error log file in the cpanel - and there is nothing related to the file i am trying to call <br /><br />Dam !<br /><br />As i mentioned earlier - when i was in the shared enviroment i had no problems calling it with an <a href="http://XXX.com/pathtofile.php" target="_blank">http://XXX.com/pathtofile.php</a><!--content-->
<!--QuoteBegin-stix+Jun 30 2005, 07:58 AM--><div class='quotetop'>QUOTE(stix @ Jun 30 2005, 07:58 AM)</div><div class='quotemain'><!--QuoteEBegin-->I looked in the error log file in the cpanel - and there is nothing related to the file i am trying to call <br /><div align="right"><a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=137773"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><!--QuoteEnd--></div><!--QuoteEEnd--><br />I don't know that you'd see errors from your script in the error log. Usually, errors that occur in a cron job are e-mailed to you. You did enter an e-mail address in the "Please enter an email address where the cron output will be sent:" box on the Cron Jobs page in CPanel, right? <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> Have you checked your e-mail to see if you've received a ton of e-mails from cron by now?<br /><br /><!--QuoteBegin-stix+Jun 30 2005, 07:58 AM--><div class='quotetop'>QUOTE(stix @ Jun 30 2005, 07:58 AM)</div><div class='quotemain'><!--QuoteEBegin-->As i mentioned earlier - when i was in the shared enviroment i had no problems calling it  with an <a href="http://XXX.com/pathtofile.php" target="_blank">http://XXX.com/pathtofile.php</a><br /><div align="right"><a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=137773"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><!--QuoteEnd--></div><!--QuoteEEnd--><br />You can't call a php script like that in a cron job, shared hosting or not. Are you sure the script is working on your new server (can you call it successfully in your browser)? What is the cron job command that you're currently trying to use?<!--content-->
Hi <br /><br /><br />I used both examples provided further up the thread - inserting the correct values !<br /><br />I filled in the email - i am not recieving anything !<br /><br />previously i used wget and i tried running to no joy !<br /><br />I am trying to run the maintance script for phpadserver !<br /><br />I keep running throu' the options, thanks for the replies !<br /><br />Stu<!--content-->
As David suggested, have you tried running the php file in your browser and does it work?<!--content-->
 
Top