开发者

Is there anyway to run PHP script automatically without user interaction? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

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


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.


add this to crontab

php -q /path/to/yourscript.php


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜