开发者

Background Processes in PHP

I am fairly new to PHP Scripting. I'm writing a game that initiates a Lottery every 24 hours. I would like this to happen at a certain time, say 3pm, regardless of users logging on to the page.

So, if 10 days goes by that no one has logged in, I would like the lottery to have run 10 times开发者_StackOverflow中文版.

I saw something for "ignore_user_abort" but I'm not familiar with this and I'm kind of afraid to use it. Is this the best way to go? Or is there a more reliable way to go?

Any ideas? And keep in mind, I'm new to this!


Use a scheduler outside of PHP such as cron to run a PHP script at set times.

Something like:

0 15 * * * /path/to/php /path/to/yourscript.php 

Here's a tutorial:
http://www.sitepoint.com/introducing-cron/


I would suggest using a Cron job for this, if you are running Linux. Google 'Cron Job'

That way, like you said, the script will run at 3 PM regardless of who is currently accessing the site.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜