Re: How to execute a script each day ?
| From: | Steve Werby | Date: | Sun, 10 Dec 2000 15:14:48 +0000 |
| Subject: | Re: How to execute a script each day ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-29561@lists.php.net to get a copy of this message | ||
"Emmanuel Halphen" <manu@halphen.net> wrote:
> thanks, but is it possible to put the execution of a php script into the
> cron ?
Yes. I use wget, but lynx and curl can be used as well (among others).
There are several downsides though.
1. The path to the script must be a FQDN, not a path on the server. The
HTTP request must go outside the server so that Apache can parse the PHP
file. That increases your bandwidth usage and if your internet connection
is down your script will fail.
2. You either have to hide the script (security by obscurity) or password
protect the file, otherwise anyone can execute your script manually (though
depending on the script that could be a feature, not a security hole). I
prefer to have scripts like this outside of the web root though.
Here is what a line in cron will look like ( remove "> /dev/null" if you
want the output of the script emailed to you):
wget -q --spider host.domain.tld/email_new_users.php > /dev/null
Altenately, you can install PHP as a binary instead of an Apache module.
Then you can call the PHP files directly without going out over the internet
and you can put the scripts outside of the web root. You can have the
Apache module version and the CGI (binary) version installed and running
simultaneously.
--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.com/