ddaugherty3
ddaugherty3

Reputation: 101

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.

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!

Upvotes: 0

Views: 106

Answers (2)

Chris Laplante
Chris Laplante

Reputation: 29658

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.

Upvotes: 1

Wiseguy
Wiseguy

Reputation: 20883

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/

Upvotes: 3

Related Questions