How to setup an automatic function? |
[eluser]KingSkippus[/eluser]
[quote author="Corey Freeman" date="1279503091"]For my game, the player's stamina needs to replenish itself automatically once every 6 hours. I thought setting up a cron job would work, but it won't run the controller that way. So I'm not sure how to go about doing this. Here's the code I have for the stamina update: <snip!> This is really important so any help is majorly appreciated![/quote] I suggest richthegeek's second method outlined above. Create a script that looks something like this: Code: <?php // refresh.php: Refresh stamina script Then use sudo crontab -e and add the following line: Code: # Run stamina refresh script every day at 2:00am To secure all of this stuff, you need to lock down the file so that other users can't read it. Assuming that you used sudo crontab -e (instead of just crontab -e), you can do so with the following commands in the directory in which refresh.php is stored: Code: sudo chown root:root refresh.php If you want to make it even more secure, create a database user account that has only update privileges on that one database or even that one table, and use that user account name and password in the script instead of an administrative account or one that has higher or unneeded privileges. That way, if by some weird chance the script is compromised, you won't have given away the keys to the kingdom, just to that one table. |
Messages In This Thread |
How to setup an automatic function? - by El Forum - 07-18-2010, 02:31 PM
How to setup an automatic function? - by El Forum - 07-18-2010, 02:41 PM
How to setup an automatic function? - by El Forum - 07-18-2010, 02:44 PM
How to setup an automatic function? - by El Forum - 07-18-2010, 03:12 PM
How to setup an automatic function? - by El Forum - 07-18-2010, 03:27 PM
How to setup an automatic function? - by El Forum - 07-18-2010, 03:36 PM
How to setup an automatic function? - by El Forum - 07-18-2010, 03:44 PM
How to setup an automatic function? - by El Forum - 07-19-2010, 03:03 AM
How to setup an automatic function? - by El Forum - 07-19-2010, 07:39 AM
How to setup an automatic function? - by El Forum - 07-19-2010, 10:03 AM
How to setup an automatic function? - by El Forum - 07-19-2010, 10:19 AM
How to setup an automatic function? - by El Forum - 07-19-2010, 02:12 PM
How to setup an automatic function? - by El Forum - 07-19-2010, 02:17 PM
How to setup an automatic function? - by El Forum - 07-19-2010, 02:30 PM
How to setup an automatic function? - by El Forum - 07-19-2010, 03:06 PM
How to setup an automatic function? - by El Forum - 07-19-2010, 04:27 PM
How to setup an automatic function? - by El Forum - 07-19-2010, 07:06 PM
How to setup an automatic function? - by El Forum - 07-19-2010, 07:31 PM
How to setup an automatic function? - by El Forum - 07-19-2010, 08:13 PM
|