Re: Can php do this?

From: Date: Sun, 25 Nov 2001 04:45:31 +0000
Subject: Re: Can php do this?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75633@lists.php.net to get a copy of this message
At 10:04 PM 11/24/2001 -0500, Joelmon2001@aol.com wrote: [snip]
Sort of like cron doing what you would do if you visited page.php and once it's hit, it emails specified users in a database Would I need path to php in the cron script to do this? Or am I just living a dream?
It sure can. There's a couple of ways to accomplish this. I personally think the easiest way is to code your page like normal, then call it in a cron job via lynx. Let's say you have a page called "page.php" that connects to your database, retrieves the email addresses, and sends the emails. To call it from a cron job add the following to your crontab: 0 8 * * * /usr/bin/lynx -dump http://localhost/page.php > /path/to/logfile/or/dev/null Of course this means your script is in your public web space, so theoretically could be called by anyone who knew the name of the page. You could put the page in a subdirectory and add an .htaccess file that restricts access to only 127.0.0.1 to take care of that if it concerns you. If you have PHP installed as a CGI then you could also write your page as a shell script. As the first line of your script put the line: #!<path to php> -q I haven't personally used this method because I have PHP installed as an apache module and I was too lazy to compile the CGI version. Using lynx in the above configuration works fine for me...

« previous php.general (#75633) next »