section31 Posted April 27, 2003 Posted April 27, 2003 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 >00**0 lynx -dump http://www.torrentlinks.com/reset.php However, I'm not sure if there is an easier way than using the lynx browser...is there? If someone could give me a nice site on sample crontabs that would help a bunch... Thanks, Dave Quote
chuckmalani Posted April 28, 2003 Posted April 28, 2003 check out this link... http://www.faqts.com/knowledge_base/view.p...id/1005/fid/436 something tells me you might not have to run it through a browser. you could do something like this... >> crontab -e (within the editor) 00 12 1 * 0 0 /home/youracct/path/to/yourscript.php 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 chuck Quote
dozure Posted April 28, 2003 Posted April 28, 2003 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 Quote
chuckmalani Posted April 28, 2003 Posted April 28, 2003 ah ok, now i learned something... thanks dozure... Quote
matman Posted April 28, 2003 Posted April 28, 2003 Not exactly true. 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. From the PHP manual: http://www.php.net/manual/en/features.commandline.php 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: #!/usr/bin/php <?php var_dump($argv); ?> Quote
DirkNiblick Posted April 29, 2003 Posted April 29, 2003 I am actually trying to run a php script from the cron. I've tried the "shell script" example and this one: * * * * * php /home/yadda/public_html/test.php 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? The e-mail contains: Content-type: text/html X-Powered-By: PHP/4.3.1 Quote
dozure Posted April 29, 2003 Posted April 29, 2003 you could set up a filter to automaticlly move messages from Cron Daemon to your trash Quote
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.