tymonhall
03-07-2001, 06:58 AM
Do any one know if its possible to run a php under cron? I need to run a script that is written as php
![]() | View Full Version : PHP ran under cron tymonhall 03-07-2001, 06:58 AM Do any one know if its possible to run a php under cron? I need to run a script that is written as php kunal 03-07-2001, 08:21 AM Well one way is to compile PHP as a CGI binary instead of as an Apache module. this should work. KDAWebServices 03-07-2001, 08:37 AM Another way is to use lynx to access the page via HTTP, you need to make sure you have all output from lynx turned off though. tymonhall 03-07-2001, 12:54 PM How would I do either one of those suggestions? Gleem 03-07-2001, 09:27 PM Using lynx you could try something like this: lynx -dump http://yourdomain.com/something.php Wazeh 03-07-2001, 11:56 PM To turn off (discard) the output of lynx, you can try this: lynx --dump http://www.yourserver.com/yourscript.php > /dev/null 3rdkynd 03-08-2001, 11:17 AM Here's an article that has info on using PHP as a shell scripting language. It should answer your question: http://www.phpbuilder.com/columns/darrell20000319.php3 tymonhall 03-08-2001, 12:52 PM Thanks all I got it to work using wget domain.com/script.php I had to go behind that script with a remove script.php because it places and output script in the same directory as the cron. But thanks for all your help. Wazeh 03-08-2001, 09:13 PM wget would work fine too. If you want a tip, no need for you to remove the file each time you run the script. Simply tell wget to discard the output like this: wget -O /dev/null http://domain.com/script.php This would discard the output instead of saving it to a file... tymonhall 03-08-2001, 11:23 PM Thanks I change the script AtlantaWebhost.com 03-09-2001, 12:44 AM To compile PHP as a CGI binary, try something like the following: ./configure \ --with-mysql=/usr/local/mysql \ --enable-track-vars \ --enable-discard-path \ --prefix=/usr/local/php \ --disable-pear make make install The PHP binary would then be located at /usr/local/php/bin/php. If you would like to make it run my simply typing php script.php at the prompt, cd into /bin and make a soft link. You can do this with: ln -s /usr/local/php/bin/php php Once you have done this, you should be able to run the scripts from a crontab with something like: 0 1 * * * php /root/admin/cpanel/process-analog-statistics.php I set up PHP on our Linux server as both a CGI binary and Apache module by compiling two copies. Best regards, Frank Rietta Si-WHN 03-09-2001, 12:58 AM we tend to use curl. Works very well, without the risk of running php as a binary. regards, Simon Ricky_1 04-02-2001, 04:02 AM I've found this on phpbuilder.com: TERM=xterm; export TERM; /usr/bin/lynx -source - "http://www.foo.com/script.php" It works great for me! Bye, Ricky |