[thelist] PHP & Chron Jobs

Kae Verens kverens at contactjuggling.org
Mon Feb 17 09:20:01 CST 2003


Paul Cohen wrote:
> Hello All.
>
> I have written a script in php that will auto generate reports from my
> database applications.  I asked my host to run a chron job every night and
> here is the response I got:
>
>
>>If you would like to have this chron job setup we will need you
>>to do one of two things. Either write this in perl, or setup a
>>perl file with a redirect to this php file in a browser.
>
>
> First, they are running PHP Ver 4.2.3 and I don't think they have the
> command line tools configured as is the default in 4.3.
>
> Rewriting this script in Perl is not an option as my skills in Perl aren't
> that great, it is a large script and frankly I don't have the time to teach
> myself.
>
> The second option seems reasonable, but I don't have a clue how to write a
> perl script that would open a browser, run my php script and do it all from
> a chron job.  This may seem like a silly question, but where would a browser
> open anyway, on the box where the web server is running?
>
> Any thoughts on this problem are appreciated.

A method I've used to run a PHP script (where console-based PHP is not
installed) is to simply wget the script, sending all output to /dev/null

Say, for example, you have a script called report.php in /cron/jobs on
your server. You would call it with this line:
* 0 * * * wget http://yourserver.com/cron/jobs/report.php -O /dev/null
 >/dev/null 2>/dev/null

If the ISP insists that you run a perl file, try this:
* 0 * * * perl /home/username/report.pl
  where report.pl is the following:
#!/usr/bin/perl
`wget http://yourserver.com/cron/jobs/report.php -O /dev/null >/dev/null
2>/dev/null`;

--
Kae Verens               _______\_   webworks.ie
work: www.webworks.ie       _____\\__   webhosts
play: www.contactjuggling.org  ___\\\___  design
kae:  kverens.contactjuggling.org _\\\\____ code




More information about the thelist mailing list