views:

336

answers:

4

hi, I want to send mail to user daily. For that I will store the database some records. The PHP Script will send each record daily as mail to the user. These should be done automatically without admin or user interaction. Please give me some help or suggestion

+6  A: 

PHP can be run from the command line like any shell script, Perl script or so on. See Using PHP from the command line.

For the daily job put such a command line in your cron. See Schedule tasks on Linux using crontab.

cletus
+3  A: 

add this to crontab

php -q /path/to/yourscript.php
Cem Kalyoncu
it is also possible in windows (PHP cli executable) c:\php\php5.exe -q c:\path\to\yourscript.php (cli executable path might be incorrect)
Cem Kalyoncu
This strikes me as a piece of "Ubuntu advice". Please explain what a crontab is, why you should run command X, and perhaps link to some resources -- like cletus' answer.
Conrad Meyer
+1  A: 

There are basically two ways to accomplish this.

The first is to configure at the operating system level to run the script at the appropriate times (e.g. cron or Windows Task Scheduler). The other option is to use a script like phpJobScheduler will will run jobs by inserting a check in your other scripts. The important thing is that you need a reasonable amount of traffic on your web server so that the check is invoked often enough.

Kitson
A: 

You could also use a webcron service to trigger your script. If you are not hosting your website on a dedicated box, you might not be able to configure crontabs.

mnml