[web] How do I make PHP game update hourly?

Started by
12 comments, last by Captain_Thunder 14 years, 11 months ago
I'd like a PHP script to run hourly. How do I go about doing this? It's for a game in which players may receive money and other forms of income at regular intervals. I'm hosting this on my own machine (windows xp) so cron jobs are out of the question. Is there a simple solution to this?
http://www.sharpnova.com
Advertisement
Configuring cron jobs on Windows
Does not work. Everytime I try to apply the new schedule, it gives an error as if the user wasn't entered correctly. Well I only have one user: Owner and this is the user I selected. Also I don't have a password on my user account so I shouldn't need to set any password.

Also, when I click the schedule tab and click advanced, the logic of the options confuses me.

Why would there be a start date, an end date, AND an amount of times to repeat ever "x" intervals of time.

Wouldn't one or the other determine when the repetition of tasks is done?

And what does it mean by duration?

If I say "start on x date" "end on y date"
repeat every 1 minute until duration 3 minutes.

wouldn't that make it repeat every minute for 3 minutes and ignore "y date"?

It seems redundant and contradictory.

But the fact that it's pretending my user account (the only one on the system.. which is not password protected) doesn't have the necessary privileges makes me think windows scheduler doesn't work.
http://www.sharpnova.com
You could try using sleep:
http://us3.php.net/sleep

Just have your hourly update function in a while(1) loop with a sleep(3600).
Check out the first gameplay video from my javascript/PHP RTS game
have you googled?
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
yes i have. and i read about the scheduler and raised the concerns i had about it here.

no responses to those concerns though.

windows scheduler does not work. it says access denied despite me having only one user account (or no user accounts depending on how you look at it) and not protected by a password.

rendering it useless.

since no one is able to get windows scheduler to work, i'll try sleep or just have a browser running with a one hour meta refresh which is what my genius mind was planning on doing from the start.
http://www.sharpnova.com
The problem you are having with the scheduled tasks is that windows xp by default doesn't allow you to run a task without a password on the account. There is however a work around, easy if you have xp pro, requires a regedit if you are on xp home. See this link for details

Follow the link, make the changes then setup your scheduled task and you should be good to go.
If PHP is the only access to the game, do lazy updates. At the top of each page call a function that makes the game 'catch up' to the present time by issuing as many 'hourly' updates as necessary. It doesn't matter if hours or days go by with nobody logging in, because as soon as someone hits a PHP page, the function gets called and every thing gets updated.
an update function that gets called on every page, a meta refresh running on the server's computer's browser, and windows scheduler were all ideas i thought of on my own.

i was hoping there was something better. something functionality built into php or sql.

thanks for your help. i'll probably use the windows scheduler workaround.
http://www.sharpnova.com
i wouldn't go around calling myself a genius if I was too moronic to configure a computer to run a script every hour.

This topic is closed to new replies.

Advertisement