February 21st, 2000, 01:36 AM
How can i do cron job for executing my PHP script once in every day...
i want to remind the people about their birthday in reminder.php.
that would be one week before thier birthday and one day before their birthday...
can i perform this action with cron job??,
Can you tell me the syntax???.
February 25th, 2000, 07:22 PM
the following is adapted from the script delivered with phpAds <http://www.phpwizard.net>. theoriginal used fetch instead of lynx which i believe is only available on FreeBSD or something...
59 23 * * * lynx -dump http://ads.ourdomain.net/mail.php3>>/var/log/messages
an alternative would be to use cgi php (which can be used at the same time as mod_php) in a script with #!/bin/php
(or whatever your path is) at the top like a perl cgi script
Use this perlscript it runs your php3 code..
activate the perlscript with cron.
my $url = shift;
$url = URI::URL::url($url, "http://www.??.??/cron.php3")->abs;
my $ua = new LWP::UserAgent;
my $request = new HTTP::Request('GET', $url);
my $res = $ua->request($request);
my $result = ($res->is_success)?$res->content:$res->error_as_HTML;
$result = $1 if $result =~ /<BODY.*?>(.*?)</BODY>/si;
$result =~ s/(<IMG.*?SRC="?)(.*?)([" >])/$1.URI::URL::url($2, $url)->abs.$3/gies;
$result =~ s/(<A.*?HREF="?)(.*?)([" >])/$1.URI::URL::url($2, $url)->abs.$3/gies;
[This message has been edited by jochum (edited June 01, 2000).]
This is how we do it here at ngenuity.
Simply compile PHP as a CGI binary and move it to somewhere convenient, such as /usr/bin/.
Then make the first line of the script
this tells the OS what program to process the script with, exacly like the famous
used in perl or the less famous
used for most shell scripts.
Then in the cron tab, you can call the script directly i.e. /data/servers/www.devshed.com/scripts/script.php
This works great, especially if it is a sensitive script... you can keep it out of your web root and accessable only to your crond.
Do be sure to keep all the script within <?php ?> tags.
Anything print()ed, or echo()ed will be output to stdout, as will anything not in <?php ?>.
One more question: what if I don't have access to cron on my unix system (I am using a host).
Is there a way to call lynx from a php page?
And then not wait for the process to finish?
Thanks so much
>>what if I don't have access to cron on my unix system
Can you run cron locally then? Or another system with cron access remotely to your unix system?
June 14th, 2000, 10:44 PM
>>what if I don't have access to cron on my unix system <<
You shouldn't have access to run cron. You need to run crontab to configure cron.
June 15th, 2000, 06:16 PM
Just goes to show you...learn something new everyday.