0

I would like to update server data to update artificial population data every minute, or every 30 seconds. I'd like to use MySQL, since I'm familiar with it and it's widely supported. I don't want to update the server just when people connect to it. How would I do that?

I've searched a bit and it seems there are a few answers that almost answer it, but they usually have something to do with users connecting.

I added "server-side-events" to the tags because I would like to send the data to anyone who is currently connected, but I want the data to keep updating even when no-one is connected.

JasonMArcher
  • 12,386
  • 20
  • 54
  • 51
JVE999
  • 2,910
  • 8
  • 41
  • 70
  • 1
    On Unix/Linux, run your update script from a cron job. I assume Windows also has a periodic scheduler that's similar. – Barmar Jul 11 '13 at 01:25

1 Answers1

1

i would create a cron task (on unix) or scheduled task (on windows) on the server. Have the script run every interval you require populate your db.

Cron
http://www.pantz.org/software/cron/croninfo.html

Windows Schedule Task (obviously you'll need to find to suit your version)
http://windows.microsoft.com/en-au/windows7/schedule-a-task

Also, cron will only run with every minute of granularity, but i found a simple solution if your wanting to run your script with more frequency than that.

#run every minute on the minute
* * * * * user /path/to/executable param1 param2
#run every minute on the minute with 30sec pause before exec.
* * * * * user ( sleep 30 ; /path/to/executable param1 param2 )

https://stackoverflow.com/a/9619441/1258598

Community
  • 1
  • 1
jammin
  • 104
  • 4
  • Thanks. This seems simple enough. I'm not sure if the server will be running Windows or Linux. I remember using Cron when I was using Linux. I'm guessing I just set it to run a php script every time interval? – JVE999 Jul 11 '13 at 02:20
  • 1
    _I'm guessing I just set it to run a php script every time interval?_ correct. – jammin Jul 11 '13 at 02:34