Jump to content

Run script every 15 mins


morrisjohnny

Recommended Posts

How would i go about making the server run a script every 15 mins?I need to add turns every 15 mins so the users has more 'turns'is it possible to change from 15 mins aswell? to change data in an sql table?what would be the best way to do it saving bandwith? or does it not use bandwidth if it being processed locally?

Link to comment
Share on other sites

There's two way to do that:1. locally on the server: on *nix use cron to run a php-script (it don't need to be a php-script...) every 15mins (what you do in the script is up to you). On win us the scheduler. Note both ways requires that you either is allowed to add "cron jobs" or scheduleitems via a wbinterfaces by your host (think it's more probably if your hosted on *nix) or that you have directaccess to the server.This is the way to preffer, but it's not often you are allowed to do it..2. on your own computer or server at home you use cron or scheduler (the same as above) that calls a script that makes a request to the script on the server every 15 min. This is easy to set up but it also less secure: anybody could potential call your script you are also depended on that your server/computer needs to be on 24/7 and you are connected to the net...The 1st doesn't take any bandwidth, the 2nd does, but not more than a normal call...

Link to comment
Share on other sites

Is their no way i could do it from a script? meaning like a count down in javascript which would countdown from 15mins down to zero then reload the page (excute the script the start over)? it would be okay if the page had to be open for it to work. since i am planning to hoest locally (depending on the costs ect) and if it is cheaper to host locally or on a server. i would still be happy with the page open. It would be great if it didn't need the page open though?

Link to comment
Share on other sites

You could use JS, but it's unnessarry complicated and not very stable.I didn't understand much of the rest, but... If you host the site yourself it should be easy to accomplish it with a cron (if you use Linux) or a scheduled event. If you need help with setting up a cron or need a "3rd party" to call the script you can contact me..

Link to comment
Share on other sites

I have an idea (never thought of it before, but I'm sure someone else has).Save a time in a database. Each time the page is loaded by anyone, check if the current time is away from the time in the database by the desired amount (15 minutes in this case). That is, if the script is executed after 15 minutes or more from the time in database, execute the action you want and then set the new time in the database. It isn't exactly running the script every 15 minutes, but everytime someone checks, the result will be as if it has.If the script is not going to be used enough, but still needs to execute, you're left with the options Mr_CHISOL suggests.

Link to comment
Share on other sites

Most hosting services offer scheduled tasks - if yours does, you should switch. Basically, you just program a web page to do whatever you want automated. The scheduled task is basically the webserver requesting a page from itself at a certain time. That, in turn, performs your automated function.Any other way will prove to be unstable or inconsistent. If you have pages check a time interval, then that is entirely dependent on your site traffic. If you run it in javascript, then that (again) is client driven which depend on traffic. If you create a local page that has a meta refresh tag set for what ever interval to load you web server page in an <iframe> or your automated task itself has a meta refresh tag, then you still have to have some page loaded in some web browser 24/7.Look at your host, thats the solution.

Link to comment
Share on other sites

Yeh I dont know about scheduling, if you just have a normal hosting plan you probably dont have the access required (from what I know anyways).If I were you I would just code it into the page. Thats what I did when I made a web based irc client. You can go about it one of two ways, either use a database like someone already suggested, or if it is a web based MMO or something like that just have it all go off the clock and calculate the differences. So essentially it just does the work whenever someone loads the page. Sorry if that wasnt a very good description Im pretty tired but I hope you get the idea.

Link to comment
Share on other sites

I'm currently at collage. although my plan is to show the servers time at the top of every page. While this requires more work than i have hoped. it would benifit me greatly. I will process the data every 15 minutes from the clock (since the clock will be a script in it's self)How do i increase a value in a database (sql) would it be VALUE ("+250")?sorted it i test to see if the IP address is the same as the servers (which could only mean the ip is the servers ip) if it is i set a refresh time in the header and if it isn't. then i redirect the "Customer" [nice work to put it :) ] back to the index page :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...