Most Efficient Cronjob To Run A Php Script

liunx

Guest
Still new at cron jobs / unix command line so go easy. Whats the most efficient way to run a php file through the crontab. The php file i plan to execute resets a certain counter in my database, i want to have this done weekly. I've come up with <br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->00**0 lynx -dump http://www.torrentlinks.com/reset.php<!--c2--></div><!--ec2--><br /><br />However, I'm not sure if there is an easier way than using the lynx browser...is there?<br /><br />If someone could give me a nice site on sample crontabs that would help a bunch...<br /><br />Thanks,<br />Dave<!--content-->
check out this link... <a href="http://www.faqts.com/knowledge_base/view.phtml/aid/1005/fid/436" target="_blank">http://www.faqts.com/knowledge_base/view.p...id/1005/fid/436</a><br /><br />something tells me you might not have to run it through a browser.<br /><br />you could do something like this...<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->> crontab -e<br /><br />(within the editor)<br />00 12 1 * 0 0 /home/youracct/path/to/yourscript.php<!--c2--></div><!--ec2--><br /><br />BUT, and this is a big but... only do this if you know what you are doing! i have never used a cron job before, so I could have told you the completely wrong thing to do!! I got my info from that site and the crontab man page<br /><br />chuck<!--content-->
don't believe a php file can be run from a command line. has to be processed by a browser. lynx is probably the best bet<!--content-->
ah ok, now i learned something...<br /><br />thanks dozure...<!--content-->
Not <i>exactly</i> true.<br /><br />PHP scripts can indeed be run from the command line or by a cron job. I'm not sure if the TCH servers are set up to allow this or not -- not sure if our cron jobs can access /usr/bin/php or not. Without shell access to experiment with the results I'd be rather wary to experiment with this.<br /><br />From the PHP manual:<br /><a href="http://www.php.net/manual/en/features.commandline.php" target="_blank">http://www.php.net/manual/en/features.commandline.php</a><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->However, there's another way of using PHP for shell scripting. You can write a script where the first line starts with #!/usr/bin/php. Following this you can place normal PHP code included within the PHP starting and end tags. Once you have set the execution attributes of the file appropriately (e.g. chmod +x test) your script can be executed like a normal shell or perl script: <br /><br />#!/usr/bin/php<br /><?php<br />??var_dump($argv);<br />?><!--QuoteEnd--></div><!--QuoteEEnd--><!--content-->
matman saves the day...<!--content-->
ahh yes i didn't think about that...<!--content-->
I am actually trying to run a php script from the cron. I've tried the "shell script" example and this one:<br /><br />* * * * * php /home/yadda/public_html/test.php<br /><br />It works alright, but it sends an e-mail from the Cron every time it executes. (it's doing it every minute for testing purposes only) Does anyone know how to prevent the e-mails?<br /><br />The e-mail contains:<br /><br />Content-type: text/html <br />X-Powered-By: PHP/4.3.1<!--content-->
you could set up a filter to automaticlly move messages from Cron Daemon to your trash<!--content-->
 
Top